申し訳ありませんが、私はアンドロイド開発に非常に慣れていないため、ユーザーがボタンを押すとActivity2が開始され、同様にユーザーがActivity2のキャンセルボタンを押すと元のアクティビティに戻ることをワークアウトしたいと思います. .
アプリの作成に関する本を参照しましたが、機能しないようです。コーディングは簡単で、次のように見えます。
public class NameIndex extends Activity
{
// called when the activity is first created
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.name_index);
public button_cancel_click (View view) { /////// <-- ERROR AT THIS LINE
Intent intent = new Intent (this, GameIndex.class);
startActivity(intent);
}
} // end method onCreate
}
xml レイアウトは次のとおりです。
<TableRow android:id="@+id/tableRow1"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:layout_span="2" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_span="1"
android:layout_weight="1"
android:onClick="button_cancel_click"
android:text="Cancel" />
</TableRow>
Eclipse は、上記のエラー行を「button_cancel_click をタイプに解決できません」と報告します。
view "パラメータ ビューの修飾子が正しくありません。final のみが許可されています"。
これはどのように解決できますか?