我在活動A的gridview中有視圖。在活動B中,如果發生某些操作,我想在gridview的視圖中添加一點複選標記。當我回到活動A時,我想在同一個網格視圖中用這個小複選標記顯示此視圖。我將如何做到這一點?在網格視圖中更改視圖
這裏是我的活動,包含網格視圖
public class LogoSelectionActivity extends Activity {
static int pos;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list_logos);
GridView gridview = (GridView) findViewById(R.id.gridview);
gridview.setAdapter(new ImageAdapter(this));
gridview.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
pos = position;
if(ImageAdapter.items[position] == 0){
Intent intent = new Intent(LogoSelectionActivity.this, LogoActivity.class);
intent.putExtra ("clicked_position", position);
startActivity(intent);
}else{
Intent intent = new Intent(LogoSelectionActivity.this, CorrectActivity.class);
startActivity(intent);
}
}
});
}
這裏是我的其他活動,我比較輸入:
public class LogoActivity extends Activity{
EditText text;
Button check;
Boolean a;
int id;
Names name;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_logo);
check = (Button) findViewById(R.id.Check_button);
text = (EditText) findViewById(R.id.editText1);
ImageView view = (ImageView)findViewById(R.id.imageView1);
final ImageView incorrect = (ImageView)findViewById(R.id.incorrect);
switch (getIntent().getIntExtra ("clicked_position", -1))
{
case 0:
view.setImageResource(R.drawable.adese);
id = R.drawable.adese;
break;
case 1:
view.setImageResource(R.drawable.birvar);
id = R.drawable.birvar;
break;
case 2:
view.setImageResource(R.drawable.agaoglu);
break;
case 3:
view.setImageResource(R.drawable.akinsoft);
break;
default:
view.setImageResource(R.drawable.afra);
id = R.drawable.afra;
}
name = Names.forDrawable(id);
check.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
a=name.isCorrect(text.getText().toString());
if(a==true){
ImageAdapter.items[LogoSelectionActivity.pos] = 1;
Intent intent = new Intent(LogoActivity.this, CorrectActivity.class);
startActivity(intent);
}
else{
incorrect.setVisibility(0);
}
}
});
}
}
如果返回true,我想提出一個小對勾當用戶返回到第一個活動時在網格視圖中查看。
我編輯我的代碼的問題。 – ocry 2013-03-03 14:42:11