AlertDialog
我在片段中工作时遇到了一些困难。我有六个按钮,当单击每个按钮时,AlertDialog
框应显示其内容。即使 prg 运行没有任何错误并且 tat 片段页面正在打开按钮,如果我单击按钮对话框没有打开,任何人都可以帮助我吗?提前致谢。
这是我的片段活动代码:
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public class Fragment3 extends DialogFragment implements OnClickListener {
private static final int ALERT_DIALOG1 = 1;
private static final int ALERT_DIALOG2 = 2;
private static final int ALERT_DIALOG3 = 3;
private static final int ALERT_DIALOG4 = 4;
private static final int ALERT_DIALOG5 = 5;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
//setContentView(R.layout.activity_fragment2);
View view = inflater.inflate(R.layout.fragment3layout, container, false);
Button alert1 = (Button) view.findViewById(R.id.Button1);
alert1.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
showDialog(ALERT_DIALOG1);
}
});
default:
dialog = null;
}
return dialog;
}
这是我的清单文件
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.pacificstereoapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
</intent-filter>
</activity>
<activity
android:name="com.example.a.Fragment1"
android:label="@string/title_activity_fragment1" >
</activity>
</application>
</manifest>