When The user Click on the button it want to call the dialog- that dialog contain list of product in ListView.After user slect the product it should come to previuous activity.
I have done using startActivityForResult ()
.
There aresome issue.My calling activity is in normal tab activity that normal tab activty in Tab Activity Group.
Actualy i want to do in drrop down(Spinner).In my scanerio i couldn't get context.It awalys give Android Spinner Error : android.view.WindowManager$BadTokenException: Unable to add window
So I have change to my design like this: When User click buttion it load the list of product in ListView.After pick the product, it come back to previous activity.
This is my previous question : link
Here calling activity:
//Click Product button
l_prod.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent showContent = new Intent(LineDiscountActivity.this,ListProductActivity.class);
Bundle bundle = new Bundle();
bundle.putString("Activity", "LineDiscountActivity");
bundle.putString("RetailerName", retailerName);
bundle.putString("RetailerCode", retailerCode);
showContent.putExtra("discountProduct", discountList);
showContent.putExtras(bundle);
getParent().startActivityForResult(showContent, 5);
}
});
And my receiver activity :
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
Object o = this.getListAdapter().getItem(position);
String book = o.toString();
Intent i = new Intent();
Bundle bundle = new Bundle();
bundle.putString("Activity", "ListProductActivity");
bundle.putString("RetailerName", retailerName);
bundle.putString("RetailerCode", retailerCode);
bundle.putString("seletcedProductCode", products.get(position).getProductCode());
bundle.putString("seletcedProductName", products.get(position).getDescription());
bundle.putDouble("seletcedProductQty", products.get(position).getAvailableQuantity());
i.putExtra("discountProduct", discountList);
i.putExtras(bundle);
if (getParent() == null) {
setResult(Activity.RESULT_OK, i);
} else {
getParent().setResult(Activity.RESULT_OK, i);
}
ListProductActivity.this.finish();
}
And calling activity
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// super.onActivityResult(requestCode, resultCode, data);
Log.i("-requestCode from LineDisocunt--" ,"" + requestCode);
}
I have written this code(onActivityResult
) in calling activity & Tab main Activty also.
I didn't go anywhere..
onActivityResult mehtod.But it didn't go it.
What is wrong in my code.
Please let me know if anybody know this...
Thanks in advance