我试图制作datePickerDialog并使用意图去那里,而是转到我没有的活动。
我的意图方法:
public void toDate(View view){
Intent i = new Intent(getApplicationContext(), DateActivity.class);
startActivity(i);
}
我的DateActivity.java类:
public class DateActivity extends AppCompatActivity implements DatePickerDialog.OnDateSetListener {
//using the datePickerDialog.
}
activity_date.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".DateActivity">
<Button
android:id="@+id/picDate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Pic Date"
android:onClick="datePicker"/>
<TextView
android:layout_below="@+id/picDate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/showDate"
android:textSize="18dp"/>
</RelativeLayout>
我按下按钮后的内容与activity_main中的所有按钮完全相同,但没有ListActivity,按钮的fontSize也相同。
答案 0 :(得分:0)
重写DateActivity.java类
public class DateActivity extends AppCompatActivity implements DatePickerDialog.OnDateSetListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_date);
//using the datePickerDialog.
}
}