我正在使用listview和textview来播放csv文件和showin它所以我想在文本的列表视图上设置setOnItemClickListener ...当我点击项目然后其他活动将被打开..所以请告诉我如何编码为此...
这是我的代码......
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
//String listItem = (String) listView.getItemAtPosition(position);
String listItem = (String) parent.getAdapter().getItem(3);
Toast.makeText(getApplicationContext(), listItem.toString(), Toast.LENGTH_SHORT).show();
Intent intent = new Intent(getApplicationContext(), Editinfo.class);
intent.putExtra("spinner", chosenOption);
startActivity(intent);
}
});
}
这是catlog报告..
12-08 11:17:28.630 20936-20936 / com.technostark.com.myloginactivity W / ResourceType:跳过包0表中的条目0x108035a因为它不复杂!
更新
<RelativeLayout
xmlns:android= "schemas.android.com/apk/res/android";
xmlns:tools= "schemas.android.com/tools";
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/shape">
<ListView android:id="@+id/editlistview"
android:layout_width="match_parent"
android:layout_height= "wrap_content" />
</RelativeLayout>
这是textview xml文件
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/et_Studname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="text"
android:hint="Student Name"
android:textColorHint="#660000"
android:textSize="20dp"
android:textColor="#660000"
android:clickable="true"
android:layout_marginLeft="15dp"
android:layout_marginTop="15dp"
android:ems="20" />
</LinearLayout>
答案 0 :(得分:1)
light.shadow.camera.left = -width / 2;
light.shadow.camera.right = width / 2;
light.shadow.camera.top = -height / 2;
light.shadow.camera.bottom = height / 2;
答案 1 :(得分:-1)
ListView list = (ListView) findViewById(R.id.listview);
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String listItem = (String) parent.getAdapter().getItem(3);
Toast.makeText(getApplicationContext(), listItem.toString(), Toast.LENGTH_SHORT).show();
Intent intent = new Intent(this, Editinfo.class);
intent.putExtra("spinner", chosenOption);
startActivity(intent);
}
});