你能给我一个简短的Android代码来创建这个吗?
如何使用Toast对象提问 我到处找了找,但找不到如何让一个烤面包的物体问问题你能给我一个简短的Android代码来创建这个吗?,android,Android,如何使用Toast对象提问 我到处找了找,但找不到如何让一个烤面包的物体问问题 非常感谢堆栈溢出实际上,这只是一个首选活动。看看JavaDoc,您看到的不是Toast通知 这是一个CustomDialog read more这是PreferenceActivity中的EditTextPreference <?xml version="1.0" encoding="utf-8"?> <PreferenceScreen xmlns:android="http://sche
非常感谢堆栈溢出实际上,这只是一个首选活动。看看JavaDoc,您看到的不是Toast通知
这是一个CustomDialog read more这是PreferenceActivity中的EditTextPreference
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:mypref="http://schemas.android.com/apk/res/com.tneele.daynightlwp"
android:title="@string/settings_title"
android:key="daynightwallpaper_settings">
<EditTextPreference
android:dialogTitle="UserName" />
</PreferenceScreen>
以下是一个示例:
解决方案是使用带有标签和文本框的布局的警报对话框
public Dialog create()
{
LayoutInflater li = LayoutInflater.from(this._context);
this._view = li.inflate(R.layout.prompt_dialog, null);
AlertDialog ad = new AlertDialog.Builder(this._context).create();
ad.setView(this._view);
if(this._title != null)
{
ad.setTitle(this._title);
}
if(this._icon != 0)
{
ad.setIcon(this._icon);
}
TextView tv1 = (TextView)this._view.findViewById(R.id.prompt_dialog_message);
tv1.setText(this._message);
ad.setButton(DialogInterface.BUTTON_POSITIVE, _context.getString(R.string.ok), this);
ad.setButton(DialogInterface.BUTTON_NEUTRAL, _context.getString(R.string.cancel), this);
return ad;
}
我在我的应急工具应用程序中使用了这些工具,我没有遇到任何问题:)这就是你发现的:嗯,事实上是的。这是一个PreferenceActivity,有人点击其中一个字段,弹出EditTextPreference。实际上这是一个对话。PreferenceActivity位于对话框下方…PreferenceActivity是一个首选项列表,实际上是一个名称所示的活动,而不是一个弹出窗口。这对于降级来说是相当挑剔的。OP发布了一个指向图形的链接,该图形显示PreferenceActivity,其上方的对话框是EditTextPreference的结果。我提供的链接可以帮助创建OP想要的东西,这就是重点。是的,没错。但是如果OP想在PreferenceActivity之外的其他地方使用它,那么AlertDialog就是一个不错的选择。我认为引用PreferenceActivity和Dialog都是准确而有用的答案。
public Dialog create()
{
LayoutInflater li = LayoutInflater.from(this._context);
this._view = li.inflate(R.layout.prompt_dialog, null);
AlertDialog ad = new AlertDialog.Builder(this._context).create();
ad.setView(this._view);
if(this._title != null)
{
ad.setTitle(this._title);
}
if(this._icon != 0)
{
ad.setIcon(this._icon);
}
TextView tv1 = (TextView)this._view.findViewById(R.id.prompt_dialog_message);
tv1.setText(this._message);
ad.setButton(DialogInterface.BUTTON_POSITIVE, _context.getString(R.string.ok), this);
ad.setButton(DialogInterface.BUTTON_NEUTRAL, _context.getString(R.string.cancel), this);
return ad;
}