如何将ListVersion中的ImageVelew传递给其他活动
当我单击复选框时,我想将ImageView和TextView传递给其他活动。 Textview okey但ImageView不起作用。如何将ListVersion中的ImageVelew传递给其他活动
(有ImageView的,TextView的和CheckBox在ListView线。)
MY第一活动
peopleList = new ArrayList<>();
intent = new Intent (dinlenmeEkrani_newOptions.this, MainActivity.class);
myTasks book = new myTasks("Reading a book",null ,"drawable://" + R.drawable.book);
myTasks watchingTV = new myTasks("Watchin TV", null ,"drawable://" + R.drawable.watchingtv);
peopleList.add(book);
peopleList.add(watchingTV);
PersonListAdapter adapter = new PersonListAdapter(this, R.layout.row_2, peopleList);
mListView.setAdapter(adapter);
FOR CHECKBOX:
holder.checkBox.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (durum=true)
intent.putExtra("RESULT_TEXT", name); }
第二个活动(只有代码传递TextView,因为我为ImageVeew尝试过的很多东西都不起作用)
Bundle bundleObject = getIntent().getExtras();
if (bundleObject != null) {
String resultText = bundleObject.getString("RESULT_TEXT");
dbHelper.insertNewTask(resultText);
loadTaskList();
我应该尝试通过ImageView的开关情况吗?我需要你的评论。
看来你没有通过TextView
,只是String
文本。你同样只是想要图像资源的URI而不是ImageView
?
如果是这种情况,请使用与存储name
到putExtra
相同的方式存储drawable
链接。
我可以TextView的工作,因为它来自database.But如果我叫不ImageView的SQLite数据库,它不工作:( 公共无效insertNewTask(字符串任务){ SQLiteDatabase DB = this.getWritableDatabase(); ContentValues值= new ContentValues(); values.put(DB_COLUMN,task); db.insertWithOnConflict(DB_TABLE,null,values,SQLiteDatabase.CONFLICT_REPLACE); db.close(); } –
您的图片是一个资源或链接? –
我在数组列表中添加了myTasks book = new myTasks(“读书”,null,“drawable://”+ R.drawable.book); –