我有一个TextView和一个ListView,它在同一个XML布局文件中填充了一个自定义适配器。 我在textview中设置了clicklistener,但没有检测到点击。我尝试了clickable =“true”和focusable =“true”属性,但这也没有用。 TextView位于片段内。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true" >
<ProgressBar
//...
/>
<TextView
android:id="@+id/nointernet"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:visibility="gone"
android:padding="20dp"
android:textSize="30sp"
android:text="Opps! looks like you are not connected to the internet. Tap here to retry!" />
<uk.co.senab.actionbarpulltorefresh.library.PullToRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
>
<ListView
//.....
/>
</uk.co.senab.actionbarpulltorefresh.library.PullToRefreshLayout>
</RelativeLayout>
nointernet = (TextView) rootView.findViewById(R.id.nointernet);
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.my_layout), container, false);
nointernet = (TextView) rootView.findViewById(R.id.nointernet);
nointernet.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Log.i("TextView", "Clicked");
}
});