В моем фрагменте у меня есть listview, и когда я нажму, откроется другое действие, которое соответствует элементу списка. Но на самом деле это не работает, и когда я нажимаю, ничего не происходит.onListItemClick прослушиватель не работает
@SuppressLint("NewApi")
protected void onListItemClick(ListView l, View v, int positionItem, long id) {
Sensor sensor = sensorAdapter.getItem(positionItem).getSensor();
String sensorName = sensor.getName();
Intent i = new Intent(getActivity(), SensorMonitor.class);
startActivity(i);
i.putExtra("sensorname",sensorName);
startActivity(i);
}
Любая помощь? LogCat ничего не говорят, если вы хотите спросить меня .. я могу нажать, но ничего не происходит .. Я также добавил в TextView из ListView:
android:focusableInTouchMode="false"
android:clickable="false"
android:focusable="false"
Но ничего
EDIT:
Это обычай TextView в ListView:
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text1"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_margin="10dp"
android:fontFamily="sans-serif-light"
android:gravity="center_vertical"
android:padding="10dp" />
И это фрагмент XML, в котором есть ListView:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<!-- Included header.xml here -->
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingTop="@dimen/activity_vertical_margin"
>
<TextView
android:id="@+id/titolodevicefragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="#DB3232"
android:textSize="18dp"
android:fontFamily="sans-serif-condensed"
android:text="@string/titolosensorsfragment" />
<ListView
android:id="@+id/listView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</TableLayout>
</LinearLayout>
андроида: focusableInTouchMode = «ложь» андроида: интерактивный = «ложный» андроида: фокусируемый = «ложь» сделать все верно .. – Avijit
Теперь я не могу щелкните на элементе. –
Вместо getActivity() использовать getApplicationContext() в намерении – Avijit