如何切换画面? [英] How to switch between screens ?

查看:108
本文介绍了如何切换画面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Android新发展的世界。
我创建简单的应用程序,我创建了一些简单的GUI一个按钮。
如果此按钮,用户preSS - 我想改变屏幕向他展示一些其他的GUI -

I'm new in the android develop world. I created simple application and i created some simple GUI with one button. If the user press on this button - i want to change the screen to show him some other GUI -

我该怎么办呢?

感谢您的帮助。

推荐答案

您执行使用这种code:

You Perform use this code:

public class Activity1 extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    Button next = (Button) findViewById(R.id.Button01);
    next.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            Intent myIntent = new Intent(view.getContext(), Activity2.class);
            startActivityForResult(myIntent, 0);
        }

    });
}
}

活动2:

public class Activity2 extends Activity {

/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main2);

    Button next = (Button) findViewById(R.id.Button02);
    next.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            Intent intent = new Intent();
            setResult(RESULT_OK, intent);
            finish();
        }

    });
}

也请务必创建的文件夹布局2个不同的XML 清单文件添加这两个活动

<activity android:name=".Activity2"></activity>

如本<一href=\"http://www.warriorpoint.com/blog/2009/05/24/android-how-to-switch-between-activities/\">example.

希望这会帮助你。

这篇关于如何切换画面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆