problem in sending image from one activity to another but able to send text to another activity, placing some source code with file name please see and correct the mistake, if possible so please writedown the required code because i am facing this problem for last two days, i have submitted this question 3 times in stackoverflow but i am not getting good answer, please someone write correct things which i need to do and write required code for me, but here i am placing some code of mine:
MainActivity Code:
list.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
// getting values from selected ListItem
String title = ((TextView) view.findViewById
(R.id.title)).getText().toString();
String artist = ((TextView) view.findViewById
(R.id.artist)).getText().toString();
String duration = ((TextView) view.findViewById
(R.id.duration)).getText().toString();
byte[] image = null;
Bitmap thumb_url = BitmapFactory.decodeByteArray
(image, 0, image.length);
// Bitmap bMap = BitmapFactory.decodeByteArray
(array, 0, array.length);
// Starting new intent
Intent in = new Intent
(getApplicationContext(), SingleMenuItemActivity.class);
in.putExtra(KEY_TITLE, title);
in.putExtra(KEY_ARTIST, artist);
in.putExtra(KEY_DURATION, duration);
in.putExtra(KEY_THUMB_URL, thumb_url);
startActivity(in);
}
});
}
}
ReceivingActivity Code:
public class SingleMenuItemActivity extends Activity {
// XML node keys
private static final String KEY_TITLE = "title";
private static final String KEY_ARTIST = "artist";
private static final String KEY_DURATION = "duration";
private static final String KEY_THUMB_URL = "thumb_url";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.single_list_item);
// getting intent data
Intent in = getIntent();
// Get XML values from previous intent
String title = in.getStringExtra(KEY_TITLE);
String artist = in.getStringExtra(KEY_ARTIST);
String duration = in.getStringExtra(KEY_DURATION);
ImageView image = (ImageView)findViewById(R.id.thumb_url);
Object thumb_url = null;
View bitmap = null;
bitmap.setBackgroundResource((Integer) thumb_url);
// Displaying all values on the screen
TextView lblName = (TextView) findViewById(R.id.name_label);
TextView lblCost = (TextView) findViewById(R.id.email_label);
TextView lblDesc = (TextView) findViewById(R.id.mobile_label);
//what code to write for image here
lblName.setText(title);
lblCost.setText(artist);
lblDesc.setText(duration);
}
}
XML File Code:
<ImageView
android:id="@+id/thumb_url"
android:layout_width="50dip"
android:layout_height="50dip"
android:src="@drawable/rihanna"/>
<TextView android:id="@+id/name_label"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="25dip"
android:textStyle="bold"
android:paddingTop="10dip"
android:paddingBottom="10dip"
android:textColor="#43bd00"/>
<TextView android:id="@+id/email_label"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#acacac"/>
<TextView android:id="@+id/mobile_label"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textStyle="bold"/>
</LinearLayout>