我在Android Studio中是新的,我想按鈕鏈接到其他網頁, 但我唯一的問題是OnClickListener,請大家幫忙;(OnClickListener,着其鏈接到另一個XML頁面佈局
標題的.java(主頁,page_title.xml)
package com.afinal.xxx.learnk;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Button;
import android.widget.TextView;
import static com.afinal.xxx.learnk.R.styleable.View;
public class Title extends AppCompatActivity {
static {
System.loadLibrary("native-lib");
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.page_title);
Button button = (Button)findViewById(R.id.title_learn);
button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent i = new Intent(this, Learn.class);
startActivity(i);
}
});
};
public native String stringFromJNI();
}
^^標題XML的按鈕(RelativeLayout的)
<Button
android:id="@+id/title_learn"
android:layout_width="200dp"
android:layout_height="100dp"
android:layout_alignStart="@+id/title_logo"
android:layout_below="@+id/title_logo"
android:layout_column="0"
android:layout_marginTop="41dp"
android:layout_row="2"
android:onClick="start"
android:text="LEARN"
android:textSize="36sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.496"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
tools:layout_constraintBottom_creator="1"
tools:layout_constraintLeft_creator="1"
tools:layout_constraintRight_creator="1" />
Learn.java(下一頁,page_learn.xml)
package com.afinal.xxx.learnk;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
public class Learn extends AppCompatActivity {
static {
System.loadLibrary("native-lib");
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.page_learn);
}
}
我使用的Android API 19更好的兼容性,是有這個問題沒有其他解決辦法?非常感謝:D
是什麼問題? –
您是否聲明瞭在Manifest文件中學習活動? – Nawaf