Thư viện tri thức trực tuyến
Kho tài liệu với 50,000+ tài liệu học thuật
© 2023 Siêu thị PDF - Kho tài liệu học thuật hàng đầu Việt Nam

Lập trình Android: Tạo DialogResult docx
Nội dung xem thử
Mô tả chi tiết
Trung tâm Tin học – ĐH KHTN
Tạo “Dialog Result”
Sau 1 thời gian mò mẫm trên layout mình phát hiện là không thể tạo ra 1 DialogResult
trên layout được. Sau cùng mình đã tìm ra cách tạo DialogResult (bảng chỉnh độ khó)
như sau:
1/ Các bạn tạo 1 project như sau:
Project name: DialogExample
Build Target: Android 2.3.3
Application name: DialogExample
Package name: org.example.DialogExample
Create Activity: DialogExample
2/Tiếp theo các bạn chỉnh sữa lại file DialogExample.java như sau:
package org.example.DialogExample;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
public class DialogExample extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
openNewGameDialog();
}
private void openNewGameDialog()
{
new AlertDialog.Builder(this)
.setTitle(R.string.new_game_title)
.setItems(R.array.difficulty,
new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialoginterface,int i)
{
}
})
.show();
}
}
Lập trình Android – http://laptrinhdidong.vn Page 1