久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Android:你如何通過點擊進入另一個活動?

Android: How do you go to another activity on click?(Android:你如何通過點擊進入另一個活動?)
本文介紹了Android:你如何通過點擊進入另一個活動?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在嘗試依次進行第三個活動.從主要活動轉到第二個活動很好,但是當我嘗試從第二個活動轉到第三個活動時,應用程序崩潰了.

I'm trying to move onto the third activity in a sequence. Going from the main activity to the second one works fine but when I try to go to the third activity from the second I the application crashes.

這是我的第二個活動的代碼:

Here's my code for the second activity:

package com.example.helloandroid;

import android.app.Activity;
//other imports here

public class Game extends Activity implements OnClickListener {

    private static final String TAG = "Matrix";

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.setContentView(R.layout.matrix);
        View doneButton = findViewById(R.id.done_button);
        doneButton.setOnClickListener(this);
    }

    public void onClick(View v) { 
        switch (v.getId()) { 
            case R.id.done_button:
                Intent k = new Intent(this, GameTwo.class);
                startActivity(k);
                //finish();
                break;
        }
    }
}

以及第三個活動的代碼:

And the code for the third activity:

package com.example.helloandroid;

import android.app.Activity;
//other imports here

public class GameTwo extends Activity {

   private static final String TAG = "Matrix";

   @Override
   public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       this.setContentView(R.layout.matrixtwo);
       View donetwoButton = findViewById(R.id.donetwo_button);
   }
}

推薦答案

switch中試試下面的代碼:

try {
    Intent k = new Intent(Game.this, GameTwo.class);
    startActivity(k);
} catch(Exception e) {
    e.printStackTrace();
}

告訴我這有用嗎.....

Tell me is this helpful.....

這篇關于Android:你如何通過點擊進入另一個活動?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to wrap text around components in a JTextPane?(如何在 JTextPane 中的組件周圍環繞文本?)
MyBatis, how to get the auto generated key of an insert? [MySql](MyBatis,如何獲取插入的自動生成密鑰?[MySql])
Inserting to Oracle Nested Table in Java(在 Java 中插入 Oracle 嵌套表)
Java: How to insert CLOB into oracle database(Java:如何將 CLOB 插入 oracle 數據庫)
Why does Spring-data-jdbc not save my Car object?(為什么 Spring-data-jdbc 不保存我的 Car 對象?)
Use threading to process file chunk by chunk(使用線程逐塊處理文件)
主站蜘蛛池模板: 天天激情综合 | 午夜视频一区 | 精品一区二区三区在线视频 | 一本一道久久a久久精品综合蜜臀 | 中文字幕中文字幕 | 国产在线高清 | 欧美在线视频一区 | 综合五月婷 | 精品国产乱码久久久久久1区2区 | 久久久久久亚洲 | 国产精品性做久久久久久 | 一本一道久久a久久精品综合 | 久久久国产一区二区三区 | 黑人性hd| 99久久精品国产麻豆演员表 | 中文字幕一区在线观看视频 | 男女羞羞的网站 | 欧美日本韩国一区二区 | 亚洲精品久久久久久国产精华液 | 黄色大片观看 | www.jizzjizz | 中文字幕 亚洲一区 | 欧美在线视频免费 | 不卡一区二区在线观看 | 国产精品免费av | 欧美a在线看 | 久久久久精| 国产熟熟 | 欧美一级电影免费观看 | 国产欧美精品一区二区色综合朱莉 | 国产日韩欧美 | 久久男人天堂 | 亚洲精品99 | 国产91九色| 久久久久久成人 | 亚洲高清在线观看 | 久久久久久av | 日日夜精品视频 | 99久久免费精品国产男女高不卡 | 97高清国语自产拍 | 欧美成人a∨高清免费观看 老司机午夜性大片 |