編輯:高級開發
警告窗口 FragmentAlertDialog
public class FragmentAlertDialog extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentVIEw(R.layout.fragment_dialog);
View tv = findVIEwById(R.id.text);
((TextVIEw)tv).setText("android123-DialogFragment Samples");
Button button = (Button)findVIEwById(R.id.show);
button.setOnClickListener(new OnClickListener() {
public void onClick(VIEw v) {
showDialog();
}
});
}
void showDialog() {
DialogFragment newFragment = MyAlertDialogFragment.newInstance( "Info");
newFragment.show(getFragmentManager(), "Title");
}
public void doPositiveClick() {
Log.i("FragmentAlertDialog", "左鍵按下");
}
public void doNegativeClick() {
Log.i("FragmentAlertDialog", "右鍵按下");
}
public static class MyAlertDialogFragment extends DialogFragment {
public static MyAlertDialogFragment newInstance(int title) {
MyAlertDialogFragment frag = new MyAlertDialogFragment();
Bundle args = new Bundle();
args.putInt("title", title);
frag.setArguments(args);
return frag;
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
int title = getArguments().getInt("title");
return new AlertDialog.Builder(getActivity())
.setIcon(R.drawable.icon)
.setTitle(title)
.setPositiveButton("ok",
new DialogInterface.OnClickListener() {
接上頁
public void onClick(DialogInterface dialog, int whichButton) {
((FragmentAlertDialog)getActivity()).doPositiveClick();
}
}
)
.setNegativeButton(R.string.alert_dialog_cancel,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
((FragmentAlertDialog)getActivity()).doNegativeClick();
}
}
)
.create();
}
}
}
上面涉及的fragment_dialog.XML布局文件代碼為:
< ?XML version="1.0" encoding="utf-8"?>
< LinearLayout XMLns:android="http://schemas.android.com/apk/res/android"
android:orIEntation="vertical" android:padding="4dip"
android:gravity="center_horizontal"
android:layout_width="match_parent" android:layout_height="match_parent">
< TextVIEw
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="center_vertical|center_horizontal"
android:textAppearance="?android:attr/textAppearanceMedium"
android:gravity="top|center_horizontal" />
< Button android:id="@+id/show"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_weight="0"
android:text="@string/show">
< requestFocus />
< /Button>
< /LinearLayout>
隨著iPad2的曝光和iOS 4.3.1的發布,Google也開始升級android 3.0系統,Xoom平板電腦將收到android 3.0.1 HRI66的更新,與
下面進行對android技術的全解讀,首先要了解下什麼是Android語言,所謂android語言:基於Linux內核的軟件平台和操作系統,早期由Google開發,後由
2010年5月20日在谷歌 I/O 2010大會上,android 2.2 Froyo正式發布。隨後在2010年12月7日夜1點,谷歌正式發布android 2.3 G
android是基於Linux內核的軟件平台和操作系統,早期由Google開發,下面介紹有關android命令的問題,希望大家看完本文章後,能夠找到自己想要的信息。每個