Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android:如何在AlertDialog中显示带有图像的复选框列表_Android_Android Alertdialog - Fatal编程技术网

Android:如何在AlertDialog中显示带有图像的复选框列表

Android:如何在AlertDialog中显示带有图像的复选框列表,android,android-alertdialog,Android,Android Alertdialog,我需要我的AlertDialog,如上图所示,但带有复选框 我已经检查了这一点,并创建了以下代码 animal_text.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout android:padding="10dp" android:layout_height="fill_parent" android:layout_width="fill_parent" android:orientation="horiz

我需要我的AlertDialog,如上图所示,但带有复选框

我已经检查了这一点,并创建了以下代码

animal_text.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:padding="10dp" android:layout_height="fill_parent"    android:layout_width="fill_parent" android:orientation="horizontal"     android:id="@+id/layout_root" xmlns:android="http://schemas.android.com/apk/res/android">

<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/miastorow_text"
    android:layout_width="fill_parent"
    android:layout_height="?android:attr/listPreferredItemHeight"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:gravity="center_vertical"
    android:checkMark="?android:attr/listChoiceIndicatorMultiple"
    android:paddingLeft="6dip"
    android:paddingRight="6dip"
    android:textColor="#000"/>
</LinearLayout>
<?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" >

<Button
    android:id="@+id/button1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Button" />

</LinearLayout>

//你复制粘贴时出错了

 _animals[0]  = new Animal( "dog", getImg( R.drawable.dog),"dog_sitting" );
_animals[1]  = new Animal( "cat", getImg( R.drawable.cat),"cat_sitting" );
_animals[1]  = new Animal( "bird", getImg( R.drawable.bird),"bird_sitting" );
//更改如下 _动物[2]=新动物(“鸟”,getImg(R.drawable.bird),“坐鸟”)

//删除下面的任何一行

 btnStart = (Button)findViewById(R.id.button1);
 final Button button = (Button) findViewById(R.id.button1);

我们不喜欢猜谜游戏,所以让LogCat看看你从哪里得到的空指针。。。我已经附加了logcat。我得到了另一个pbm。如果我单击该项,则复选框未被选中(即未被选中)…PLZhelp@Deepak在你的线性布局中,你需要提到android:checked=“false”,。。。它不工作,先生。它在setSingleChoiceItems的listner的onClick中gng,但复选框未被选中
 _animals[0]  = new Animal( "dog", getImg( R.drawable.dog),"dog_sitting" );
_animals[1]  = new Animal( "cat", getImg( R.drawable.cat),"cat_sitting" );
_animals[1]  = new Animal( "bird", getImg( R.drawable.bird),"bird_sitting" );
 btnStart = (Button)findViewById(R.id.button1);
 final Button button = (Button) findViewById(R.id.button1);