我正在使用listview ...我尝试在项目列表中点击列表时打开图像,并且在另一个活动中显而易见......但它不起作用...如果知道你知道的话请帮助我...谢谢......
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Find the ListView resource.
mainListView = (ListView) findViewById( R.id.mainListView );
mainListView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> mainListView, View view, int pos,
long id) {
//Object obj = getFilesDir().getPath();
//String value= obj.toString();
Intent intent= new Intent(SimpleListViewActivity.this,Nextclass.class);
final String root = Environment.getExternalStorageDirectory().getAbsolutePath();
intent.setData(Uri.parse(root + "/mnt/sdcard/dcim/100andro/koala_copy.jpg"));
startActivity(intent);
}
private ArrayAdapter<String> getListAdapter() {
// TODO Auto-generated method stub
return null;
}
我的main.xml是
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/mainListView">
</ListView>
</LinearLayout>
答案 0 :(得分:0)
我们也需要查看NextClass
的代码,因为这是接收你正在启动的Intent的内容。它应该是Activity
的子类。然后在onCreate
或onResume
中调用getIntent()
,检查意图是否包含您需要的额外/数据,并将图像加载到ImageView
或其他内容。< / p>