我正在尝试dialog
显示一个框。现在程序没有崩溃,所以没有 LogCat 可以显示。单击按钮时,什么也看不到。我是否缺少一行代码阻止该dialog
框显示?
Java代码:
public class Results extends Activity {
Button detailsBtn;
final Context context = this;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.resultsmain);
detailsBtn = (Button)findViewById(R.id.detailsBtn);
detailsBtn.setText("Details");
detailsBtn.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
final Dialog dialog = new Dialog(context);
dialog.setContentView(R.layout.resultsdetailsdisplay);
dialog.setTitle("Detailssss - TESTING");
TextView title = (TextView)dialog.findViewById(R.id.title);
title.setText("TITLE - TESTING");
Button close = (Button)dialog.findViewById(R.id.close);
close.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
dialog.dismiss();
}
});
}
});
}
}
结果详细信息显示.xml:
<RelativeLayout
xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/scroll" >
<TextView
android:id="@+id/title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="12sp"
android:layout_centerHorizontal="true"
android:gravity="center" />
</RelativeLayout>