クリックすると別のインテントが表示されるボタンを作成したいと思います。setOnClickListenerエラー - シンボルを解決できません
これはコードです:
<Button
android:text="Bine ati venit!"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/button1"
android:background="#479fc7"
android:textSize="40dp"
android:textColor="@color/colorPrimaryDark"
android:textStyle="normal|bold|italic"
android:textAllCaps="false"
android:fontFamily="casual"
android:onClick="next_page"/>
との.javaクラスから:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_welcome);
}
Button button = (Button) findViewById(R.id.button1);
button.setOnClickListener(new View.OnClickListener()
{
public void onClick (View v){
next_page(v);
}
});
public void next_page(View v) {
Intent intent = new Intent(this, MapsActivity.class);
startActivity(intent);
}
私はエラーを取得: は、 "シンボルを解決できません 'setOnClickListener'"、「変数のonClickは決してありません";"、 "expected" ...
を、それを使用しない場合は
next_page()
にViewオブジェクトを渡す必要はありません'onCreate'メソッドの中の' button'ですか? –xmlファイルにすでにandroid:onClick = "next_page"というタグを設定しているので、ボタンのinitを削除でき、onClickListener –
ああ、私はそれを見ていない... thx! – rocko