我在主activity里面设置了有三个tab的切换卡,在第三个tab里面是个ListView,单击ListView会弹出时间选择对话框
public void onSetWarn(){
LayoutInflater factoryInflater = LayoutInflater.from(MainActivity.this);
final View dialogView = factoryInflater.inflate(R.layout.dialog, null);
AlertDialog dialog = new AlertDialog.Builder(MainActivity.this).setTitle("设置")
.setView(dialogView)
.setPositiveButton("确定", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(getApplicationContext(), "设置成功!", Toast.LENGTH_SHORT).show();
}
})
.setNegativeButton("取消", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
}).create();
/*
timePicker = (TimePicker) this.findViewById(R.id.TimePicker1);
timePicker.setIs24HourView(true);
*/
dialog.show();
}我到底该把timePicker = (TimePicker) this.findViewById(R.id.TimePicker1);
timePicker.setIs24HourView(true);
这段代码放在哪呢? 我试了好几个地方都是NULL pointer错误
解决方案 »
- 疯掉了折腾了一个晚上,关于APP图标透明问题
- android 程序突然停住报了个非常奇怪的问题!!!!!!!!!!
- 如何得到手机QQ的好友列表最近联系人列表?
- 求帮助
- view中如何用代码动态添加图像按钮
- android中的camera的AutoFocusCallback接口
- 怎么样使用Android不开放的package(com.android.*) ?
- 如何获取系统是什么型号
- 如果在两个activity里面传递数值
- 求Android技术文档翻译[Supporting Multiple Screens]
- 为什么设置了layout_gravity="right",按钮不会到右边?
- 大家有做跨平台移动开发的吗?比如使用phonegap什么的
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="提醒时间"
/>
<TimePicker
android:id="@+id/TimePicker1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="提醒方式"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<CheckBox
android:id="@+id/checkBox1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="铃声"
/>
<CheckBox
android:id="@+id/checkBox2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="震动"
/>
</LinearLayout>
</LinearLayout>
this换成dialogView,