Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to Call back data from child Activity and make the images in parent activity transparent
    text
    copied!<p>I have images in gridview. These images are shown in an activity. When one of the images is clicked, new activity is started with this image. In this activity, If user inputs correct answer, new activity is started that indicates the answer is correct. After user inputs correct answer, I want to set this image more transparent with a check mark in gridwiew.</p> <pre><code>@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_level1); initComponent(); gva.setAdapter(new ImageAdaptera(getApplicationContext())); gva.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView&lt;?&gt; parent, View v, int position, long id) { switch (position) { case 0: { Intent intenta = new Intent (getBaseContext(), AA.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivityForResult(intenta,0); } break; case 1: { Intent intentb = new Intent (getBaseContext(), AB.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivityForResult(intentb,0); } break; case 2: { Intent intentc = new Intent (getBaseContext(), AC.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivityForResult(intentc,0); } break; }} </code></pre> <p>}</p> <p>My Image Adapter:</p> <pre><code>public View getView(int position, View convertView, ViewGroup parent) { ImageView imageViewa; if (convertView == null) { // if it's not recycled, initialize some attributes imageViewa = new ImageView(mContext); imageViewa.setLayoutParams(new GridView.LayoutParams(85, 85)); imageViewa.setScaleType(ImageView.ScaleType.CENTER_CROP); imageViewa.setPadding(8, 8, 8, 8); } else { imageViewa = (ImageView) convertView; } imageViewa.setImageResource(imagesa[position]); return imageViewa; } </code></pre> <p>Child Activity:</p> <pre><code> @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if ((event.getAction() == KeyEvent.ACTION_DOWN) &amp;&amp; (keyCode == KeyEvent.KEYCODE_ENTER)) { String check = input.getText().toString().replace(" ",""); Editor editor = mGameSettings.edit(); editor.putString(GAME_PREFERENCES_answeraa, check); editor.commit(); if(check.equalsIgnoreCase("petronet")){ display.setText("correct"); Toast.makeText(AA.this,"CORRECT",Toast.LENGTH_SHORT).show(); Intent data = new Intent(); // TODO Add extras or a data URI to this intent as appropriate. setResult(RESULT_OK, data); input.setEnabled(false);Guruapp.levela++;Guruapp.count++; int hc2 = mGameSettings.getInt(GAME_PREFERENCES_hint, Guruapp.count); Guruapp.count = hc2; finish(); } else{ display.setText("Wrong"); Toast.makeText(AA.this,"WRONG",Toast.LENGTH_SHORT).show(); return false; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload