I am using Tabwidget, Tab are implemented in same way which shows in tutorial
"MainActivity -> Activity1 -> Activity2(given Image)"
Now clicking on the spinner gives
android.view.WindowManager$BadTokenException: Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord@44eb8748 is not valid; is your activity running?
I have tried Android Spinner Error : android.view.WindowManager$BadTokenException: Unable to add window already but that doesn't help me
I know There is something wrong with context but I can't figure out what
Hear is my Intent which starts DetailActivity
intent = new Intent(getParent(), DetailActivity.class);
TabGroupActivity parentActivity = (TabGroupActivity)getParent();
parentActivity.startChildActivity("SelectActivity", intent);
My code for the DetailActivity
given bellow
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.package_detail);
setUpViews();
id = getIntent().getExtras().getInt("WEBSITE_ID");
adapter = new KeywordAdapter(getApplicationContext(), id,
getLNApplication().getKeyworddetail());
listTags.setAdapter(adapter);
spinneAdapter = new SpinnerListAdapter();
spinnerList.setAdapter(spinneAdapter);
spinnerList.setSelection(id, true);
spinnerList
.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent,
View view, int position, long id) {
// txtHeader.setText(getLNApplication().getWebsiteList()
// .get(position).getName());
adapter.forceReload();
adapter = new KeywordAdapter(DetailActivity.this,
position, getLNApplication().getKeyworddetail());
listTags.setAdapter(adapter);
}
public void onNothingSelected(AdapterView<?> parent) {
}
});
}
code for SpinnerAdapter
public class SpinnerListAdapter extends BaseAdapter {
private List<ClientDetail> siteList;
public SpinnerListAdapter() {
siteList = getLNApplication().getWebsiteList();
}
public void forceReload() {
notifyDataSetChanged();
}
@Override
public int getCount() {
return siteList.size();
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return siteList.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = convertView;
// LayoutInflater inflater = (LayoutInflater) context
// .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// LayoutInflater inflater = getLayoutInflater();
// LayoutInflater inflater = LayoutInflater.from(DetailActivity.this.getParent());
LayoutInflater inflater = LayoutInflater.from(DetailActivity.this.getParent());
view = inflater.inflate(R.layout.spinner_item_display, null);
TextView websiteName = (TextView) view.findViewById(R.id.spinnerItem);
if (siteList.get(position).getName() != null) {
websiteName.setText(siteList.get(position).getName());
websiteName.setTextColor(0xFF000000);
}
return view;
}
@Override
public View getDropDownView(int position, View convertView, ViewGroup parent) {
View view = convertView;
// LayoutInflater inflater = (LayoutInflater) context
// .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// LayoutInflater inflater = getLayoutInflater();
// LayoutInflater inflater = LayoutInflater.from(DetailActivity.this.getParent());
LayoutInflater inflater = LayoutInflater.from(DetailActivity.this.getParent());
view = inflater.inflate(R.layout.spinner_dropdown_display, null);
TextView websiteName = (TextView) view.findViewById(R.id.spinnerDropDownItem);
if (siteList.get(position).getName() != null) {
websiteName.setText(siteList.get(position).getName());
websiteName.setTextColor(0xFF000000);
}
return view;
}
}
Am i doing anything wrong?
please help me with... Thank you so much