私はこのおなじみのシナリオに取り組むことができません。
私のプロジェクトでは、ActionBarSherlockを使用しており、Search icon
クリックすると、ActionBarをカスタムレイアウトに置き換えています。問題は、この新しいレイアウトからonClickListenerとすべてのビューを取得するにはどうすればよいですか?
public boolean onCreateOptionsMenu(Menu menu) {
menu.add("Search")
.setIcon(R.drawable.ic_search)
.setActionView(R.layout.on_search_icon_clicked)
.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS |MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
return true;
}
my on_search_icon_clicked.xml is:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/search_image"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentRight="true"
android:src="@drawable/ic_search" />
<EditText
android:id="@+id/search_editText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/search_image"
android:hint="@string/search"
android:singleLine="true" />
</RelativeLayout>
今、これsearch_image.setOnClickListener
とすべてを取得する方法は?
NullPointerException
onCreateでこれを使用しているかどうかが表示されます。
ありがとうございました