AutoCompleteTextView を使用して DialogBox を作成しようとしています。オートコンプリート リストとすべてを表示することもできます。問題は、ドロップダウン リストのビューをカスタマイズできないことです。
これは私がメイン アクティビティで行っていることです。
DialogBox DB = new DialogBox(MyActivity.this);
DB.createDialog();
そして、私が作成した別のクラスでは:
public DialogBox(Context c)
{
context = c;
}
public void createDialog()
{
AlertDialog.Builder builder = new AlertDialog.Builder(context);
LayoutInflater inflater = ((Activity) context).getLayoutInflater();
final View PopupLayout = inflater.inflate(R.layout.dialog_box, null);
builder.setView(PopupLayout);
//Autocomplete:
final AutoCompleteTextView textView = (AutoCompleteTextView) PopupLayout.findViewById(R.id.autocomplete_companies);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(context, R.layout.dialog_box, R.id.autocomplete_companies, COMPANIES);
textView.setAdapter(adapter);
}
R.layout.dialog_box を変更しようとすると、NullPointerExceptions またはその他のエラーが発生します。
編集:これは私のxmlです
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageView
android:layout_width="match_parent"
android:layout_height="64dp"
android:background="#FFFFBB33"
android:contentDescription="@string/app_name"
android:scaleType="center" />
<AutoCompleteTextView
android:id="@+id/autocomplete_companies"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:hint="Company Name" />
<EditText
android:id="@+id/username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_marginTop="16dp"
android:hint="@string/username"
android:inputType="textEmailAddress" />
<EditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_marginTop="4dp"
android:fontFamily="sans-serif"
android:hint="@string/password"
android:inputType="textPassword" />
私が間違っていることは何か分かりますか??