2012-01-21 7 views
1

ポップアップを作成し、その中に2つのImageViewアイテムを持つXMLレイアウトを割り当てるコードがあります。AlertDialog.Builder内のImageViewにどうやってアクセスできますか?

popupWindow.setTitle("New note"); 
popupWindow.setMessage("choose the type of note to create"); 

View noteChoices = inflater.inflate(R.layout.addnotepopup, null); 
popupWindow.setView(noteChoices); 

popupWindow.setPositiveButton(null, null); 

popupWindow.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { 
    @Override 
    public void onClick(DialogInterface dialog, int which) { 
     // 
    } 
}); 

popupWindow.show(); 

addnotepopup.xmlは、私は、これらの二つの項目にクリックリスナーを追加することができますどのように2つのImageViewの項目

を持っていますか?私は、他のボタンと、それを同じようにやってみた場合、findViewById()、null値

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="horizontal" 
    android:weightSum="2" > 

    <ImageView 
     android:id="@+id/recordnoteoption" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:paddingTop="10dp" 
     android:paddingBottom="10dp" 
     android:src="@drawable/medium_mic" 
     android:layout_weight="1" /> 

     <ImageView 
      android:id="@+id/typenoteoption" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:paddingTop="10dp" 
      android:paddingBottom="10dp" 
      android:src="@drawable/medium_keyboard" 
      android:layout_weight="1" /> 

</LinearLayout> 
+0

plsは 'R.layout.addnotepopup'のxmlレイアウトを配置しますか? 'findViewById'にあなたが使っているコードも入れてください。 – havexz

答えて

1

はこのお試しください:

popupWindow.findViewById(R.id.yourId); 

たりしたい場合は:

noteChoices.findViewById(R.id.yourId); 
+0

noteChoicesを使用して、popupWindow.findViewById()を使用してみましたが、動作していませんでした...ありがとう! – jchmski

関連する問題