私はかなり新しいアンドロイドプログラミングですが、通常は検索で私の問題に私の答えを見つけることができますが、この1つは私はちょうど傾けると非常に混乱。 コード自体に問題の兆候は見られませんが、よく2つのJava例外ブレークポイントがありますが、「不明」なのでそれらを修正する方法はわかりませんが、エミュレータでアプリケーションを実行するとアプリケーションが予期せず停止した強制終了。私はそれをデバッグしようとするが、私はそれをうまくやる方法を知らない。任意の方法はここにコードがbtwは、アプリケーションをテストするだけで、私は他の "ページ"に戻って私を連れて行くボタンがあることです。助けていただければ幸いです。アプリケーションが動作していない、初心者
メインjavaファイルのメインXMLさてここで
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<Button android:text="pagetwo" android:id="@+id/pagetwo" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
</LinearLayout>
が、私はこの1つにコードを変更するものである
package com.simbestia.original;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class original extends Activity implements View.OnClickListener {
Button button1, button2;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
button1 = (Button) findViewById(R.id.pagetwo);
button2 = (Button) findViewById(R.id.main);
button1.setOnClickListener(this);
button2.setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.pagetwo:
setContentView(R.layout.pagetwo);
break;
case R.id.main:
setContentView(R.layout.main);
break;
}
}
}
はちょうどボタン一つであるが、それは複数で動作し、私はすべてのクラスを作りましたページ...
package com.simbestia.test;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class main extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button mainmenu = (Button) findViewById(R.id.mainmenu);
mainmenu.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent myIntent = new Intent(view.getContext(), mainmenu.class);
startActivityForResult(myIntent, 0);
}
});
}
}
どのように私はそのすべての良い私は再び同じだと思ったのですか?
あなたはどんなふるまいを見ていますか、見ていませんか?コードで問題が発生していることは実際には決して説明しませんでした。 –
あなたが問題を知っていることがわかりません(笑)私が知っているのは、エミュレータがアプリケーションを実行していないことです。 – ElBorrego
main.xmlの外観はどうですか?それも投稿できますか? –