Android 包含自定义视图(如两个textview)时,AutoCompleteTextView项目不可单击
这是自定义视图布局.xmlAndroid 包含自定义视图(如两个textview)时,AutoCompleteTextView项目不可单击,android,android-custom-view,autocompletetextview,Android,Android Custom View,Autocompletetextview,这是自定义视图布局.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="25dp" android:background="@drawable/ne
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="25dp"
android:background="@drawable/newbackrow"
android:clickable="true"
android:orientation="vertical" >
<TextView
android:id="@+id/txt_search_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="15dp"
android:layout_toLeftOf="@+id/txt_search_sport"
android:layout_weight="1"
android:focusable="false"
android:inputType="textMultiLine"
android:maxLines="2"
android:singleLine="false"
android:text="TextView"
android:textColor="@android:color/white"
android:textSize="13dp"
android:textStyle="bold" />
<TextView
android:id="@+id/txt_search_sport"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:focusable="false"
android:layout_marginLeft="10dp"
android:background="@color/red"
android:padding="0dp"
android:text="TextView"
android:textColor="@android:color/white"
android:textSize="10dp"
android:textStyle="bold" />
</RelativeLayout>
//使用getview()方法进行布局充气
查看完美显示,但它不可点击,让我建议哪里出错或其他
**//autocompletetextview和McClickListener**
search_text.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapter, View myView, int position,
long arg3) {
Toast.makeText(getApplicationContext(), "Position = "+position, Toast.LENGTH_LONG).show();
}
}
search\u text.setOnItemClickListener(新的OnItemClickListener(){
@凌驾
公共控件单击(适配器视图适配器、视图myView、int位置、,
长arg3){
Toast.makeText(getApplicationContext(),“Position=“+Position,Toast.LENGTH_LONG).show();
}
}
位置为int,使用此选项将其转换为stringy u。请使用search\u text.addTextChangedListener(new TextWatcher(){您可以在自定义适配器中单击位置,请创建自定义适配器