简体   繁体   English

Android-创建“转到下一页”按钮

[英]Android - creating a “to next page” button

i have this code but every time i run the app and click on my button it crashes and i don't get why.. am i doing something wrong here any help would be great thanks 我有这段代码,但是每次我运行该应用程序并单击我的按钮时,它都会崩溃,我不明白为什么..我在这里做错什么了,任何帮助将非常感谢

im trying to got to the "Sec.class" page/class 我正在尝试进入“ Sec.class”页面/类

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

        View continueButton = findViewById(R.id.continue_button);
        continueButton.setOnClickListener( (OnClickListener) this);
    }

    //@Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
        switch (v.getId()) {
        case R.id.continue_button:
            Intent i = new Intent(this, Sec.class);
            startActivity(i);           
            break;
        }

    }

THIS IS WHAT I WAS MISSING IN THE MANISFEST.XML FILE 这是我在MANISFEST.XML文件中缺少的内容

and i want to slap the person who downgraded my question 我想打个打消我问题的人

 <activity android:name=".Sec"
android:label="@string/sec" >
</activity>

Check that you've declared an <activity> tag for the Sec activity in your AndroidManifest.xml . 检查您是否已在AndroidManifest.xmlSec活动声明了<activity>标记。

But posting (or simply reading) the crash stacktrace from logcat would be more instructive. 但是从logcat发布(或只是读取)崩溃堆栈logcat将更具启发性。

Without knowing what the error is, it is really hard to guess what the problem is, but usually when this happens, the button ( continueButton in your case) could not be found in the layout. 不知道错误是什么,真的很难猜出问题是什么,但是通常在发生这种情况时,在布局中找不到按钮(在您的情况下为continueButton )。 So make sure that you have a View with id continue_button in main.xml . 因此,请确保在main.xml具有ID为continue_button的View。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM