您的位置:首页 > 移动开发 > Android开发

android自定义对话框

2012-02-08 17:04 357 查看
布局文件

agg_attack_text_list.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView android:id="@+id/text_attack_text_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="所需物品"/>
<ListView android:id="@+id/list_attack_text_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/transparent"/>
</LinearLayout>


JAVA代码

public class AggKillGhostGoodsListDlg extends AlertDialog {
private final Context mContex;
TextView mMessage = null;
ListView mListView = null;
MyListAdapter mMyAdapter = null;

@Override
protected void onCreate(Bundle savedInstanceState) {
//此处仅一个简单的TextView,可以扩展到自定义xml里面
LayoutInflater factory = LayoutInflater.from(mContex);
LinearLayout layout =(LinearLayout) factory.inflate(R.layout.agg_attack_text_list, null);
setTitle(mContex.getResources().getString(R.string.kill_ghost_need_goods));
setButton(mContex.getResources().getString(R.string.OkButton), new OnClickListener() {
public void onClick(DialogInterface dialogInterface, int i) {
//To change body of implemented methods use File | Settings | File Templates.
Log.d(TAG, "onClick");
}
});
setView(layout);
super.onCreate(savedInstanceState);

mMessage = (TextView) findViewById(R.id.text_attack_text_list);//new ListView(mContex);
mListView = (ListView) findViewById(R.id.list_attack_text_list);//new ListView(mContex);
mMyAdapter = new MyListAdapter(mContex, R.layout.agg_box_open_dlg, mAllGoodsList);
mListView.setAdapter(mMyAdapter);

}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: