I'm trying to create a textView in the parent activity onActivityResult but the textView does not appear. There is an ImageView that takes up the whole parent activity. I can create a textView and place it, and it should go on top of the imageView?
In the parent class:
[HIGH]private void addClothes(int menuId) {
Intent chooseClothesIntent = new Intent(this, ChooseClothesActivity.class);
chooseClothesIntent.putExtra("menuId", menuId);
startActivityForResult(chooseClothesIntent, 1);
}[/HIGH]
[HIGH]@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch(requestCode) {
case (1) : {
if (resultCode == Activity.RESULT_OK) {
String newText = data.getStringExtra("imagePath");
TextView tv = new TextView(this);
tv.setTextSize(10);
tv.setTextColor(Color.RED);
tv.setText(newText);
LayoutParams lp = new LayoutParams(new ViewGroup.MarginLayoutParams(100,100));
//tv.setLayoutParams(lp);
//((MarginLayoutParams) lp).setMargins((int)texts.get(index).Sx, (int)texts.get(index).Sy, (int)texts.get(index).Lx, (int)texts.get(index).Ly);
tv.setLayoutParams(lp);
Log.d("tag", "I have set the text " + newText); //Logs successfully. newText is set correctly
}
break;
}
}
}[/HIGH]
then in my new activity:
[HIGH]@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
try {
ClothingItem ci = mListContents.get(position);
String imagePath = ci.getImagePath();
Log.d("path", imagePath); //this successfully logs the imagePath string
Intent resultIntent;
resultIntent = new Intent(this, DressingRoomActivity.class);
resultIntent.putExtra("imagePath", imagePath);
setResult(Activity.RESULT_OK, resultIntent);
finish();
} catch (Exception e) {
Log.v(TAG, e.getMessage());
}
}[/HIGH]
In the parent class:
[HIGH]private void addClothes(int menuId) {
Intent chooseClothesIntent = new Intent(this, ChooseClothesActivity.class);
chooseClothesIntent.putExtra("menuId", menuId);
startActivityForResult(chooseClothesIntent, 1);
}[/HIGH]
[HIGH]@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch(requestCode) {
case (1) : {
if (resultCode == Activity.RESULT_OK) {
String newText = data.getStringExtra("imagePath");
TextView tv = new TextView(this);
tv.setTextSize(10);
tv.setTextColor(Color.RED);
tv.setText(newText);
LayoutParams lp = new LayoutParams(new ViewGroup.MarginLayoutParams(100,100));
//tv.setLayoutParams(lp);
//((MarginLayoutParams) lp).setMargins((int)texts.get(index).Sx, (int)texts.get(index).Sy, (int)texts.get(index).Lx, (int)texts.get(index).Ly);
tv.setLayoutParams(lp);
Log.d("tag", "I have set the text " + newText); //Logs successfully. newText is set correctly
}
break;
}
}
}[/HIGH]
then in my new activity:
[HIGH]@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
try {
ClothingItem ci = mListContents.get(position);
String imagePath = ci.getImagePath();
Log.d("path", imagePath); //this successfully logs the imagePath string
Intent resultIntent;
resultIntent = new Intent(this, DressingRoomActivity.class);
resultIntent.putExtra("imagePath", imagePath);
setResult(Activity.RESULT_OK, resultIntent);
finish();
} catch (Exception e) {
Log.v(TAG, e.getMessage());
}
}[/HIGH]