请与StaticClass按钮可见,并将其保存

编程入门 行业动态 更新时间:2024-10-24 00:30:48
本文介绍了请与StaticClass按钮可见,并将其保存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我还是弄糊涂了与我的朋友这给替代节省除了共享preferences StaticClass code,已经3天我试着学会了code和要求,但仍有小问题,一个code

I still got confused with StaticClass code which given from my friend to alternative save besides Shared Preferences, already 3 days I tried learned the code and asked but there is still a little problem with a code

这是最新以下code在我的 selectlevel.class ,我已经完善

this is the latest following code in my selectlevel.class that i have perfected

public class selectlevel extends Activity { Button f1, f2, f3; ImageView f2lock, f3lock; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.selectlevel); f1=(Button)findViewById(R.id.f1); f1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v){ // TODO Auto-generated method stub Intent level1 = new Intent (); level1.setClassName ("com.example.game", "com.example.game.levelone"); startActivity (level1); } }); f2=(Button)findViewById(R.id.f2); f2lock=(ImageView)findViewById(R.id.f2lock); f2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v){ // TODO Auto-generated method stub Intent level2 = new Intent (); level2.setClassName ("com.example.game", "com.example.game.leveltwo"); startActivity (level2); } }); updateLevels(); } static class PlayerProgress { private static int progress = 0; public static void updateProgress(int levelNumber) { progress = levelNumber; } public static int getPlayerProgress() { return progress; } } public void updateLevels() { int progress = PlayerProgress.getPlayerProgress(); switch(progress) { case 1: f2.setVisibility(View.VISIBLE); f2lock.setVisibility(View.GONE); break; case 2: break; // You can expand this to as many levels you'd like. } }

和我有使用这在我的 levelone.class 发送更新进度1

and i had use this in my levelone.class to send update progress to 1

button1.setOnClickListener(new View.OnClickListener() { public void onClick(View v){ selectlevel.PlayerProgress.updateProgress(1); finish();

但 levelone.class 完成,F2键还是走了,f2lock仍可见

but when levelone.class finish, f2 button still GONE and f2lock still VISIBLE

没有什么变化 selectlevel.class

我不知道它可以是可见这样,仍然可见,如果本场比赛再开,因为按钮知名度保存

i wonder it can be visible like this and still visible if the game re-open because the button visibility is saved

谁能帮我解决我的code的一个问题?或给另一个code作为解决方案,解释一下吗?

can anyone help me to fix a problem in my code? or give explain with another code as solution?

推荐答案

尝试调用 updateLevels()功能也在你的onClick funtion是这样的:

try to call the updateLevels() function also in your onClick funtion like this:

button1.setOnClickListener(new View.OnClickListener() { public void onClick(View v){ selectlevel.PlayerProgress.updateProgress(1); selectlevel.PlayerProgress.updateLevels(); finish(); }

更多推荐

请与StaticClass按钮可见,并将其保存

本文发布于:2023-10-11 23:24:13,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1483132.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:请与   按钮   并将其   StaticClass

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!