android – 在AlertDialog中显示微调器

android – 在AlertDialog中显示微调器,第1张

概述我想在alertDialog中显示一个微调器.我有以下代码,但它只是给我一个黑屏. Logcat没有说出任何错误. MyActivity.java AlertDialog.Builder builder;AlertDialog alertDialog;Context mContext = getApplicationContext();LayoutInflater inflater = ( 我想在alertDialog中显示一个微调器.我有以下代码,但它只是给我一个黑屏. Logcat没有说出任何错误.

MyActivity.java

AlertDialog.Builder builder;AlertDialog alertDialog;Context mContext = getApplicationContext();LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(LAYOUT_INFLATER_SERVICE);VIEw layout = inflater.inflate(R.layout.spinner,null);String array_spinner[];array_spinner=new String[5];array_spinner[0]="US";array_spinner[1]="Japan";array_spinner[2]="China";array_spinner[3]="India";array_spinner[4]="VIEtnam";Spinner s = (Spinner) layout.findVIEwByID(R.ID.Spinner01);ArrayAdapter adapter = new ArrayAdapter(this,androID.R.layout.simple_spinner_item,array_spinner);s.setAdapter(adapter);builder = new AlertDialog.Builder(mContext);builder.setVIEw(layout);alertDialog = builder.create();

main.xml中

<?xml version="1.0" enCoding="utf-8"?><linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"    androID:layout_wIDth="fill_parent"    androID:layout_height="fill_parent"    androID:orIEntation="vertical" >    <TextVIEw        androID:layout_wIDth="fill_parent"        androID:layout_height="wrap_content"        androID:text="@string/hello" /></linearLayout>

Spinner.xml

<?xml version="1.0" enCoding="utf-8"?><linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"    androID:layout_wIDth="fill_parent"    androID:layout_height="fill_parent"    androID:orIEntation="vertical" >    <Spinner        androID:ID="@+ID/Spinner01"        androID:layout_wIDth="match_parent"        androID:layout_height="wrap_content" /></linearLayout>

我真的很新,非常感谢你的帮助! 总结

以上是内存溢出为你收集整理的android – 在AlertDialog中显示微调器全部内容,希望文章能够帮你解决android – 在AlertDialog中显示微调器所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1129648.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存