feedLayout = new LinearLayout(this);
feedLayout.setOrientation(LinearLayout.VERTICAL);
//LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = getLayoutInflater().inflate(R.layout.list_feeds, feedLayout, false);
lstFeeds = (ListView) v.findViewById(R.id.listfeeds);
lstFeeds.setAdapter(new FeedsAdapter(this, android.R.layout.simple_list_item_1, lista));
feedLayout.addView(lstFeeds);
Logcat:
IllegalStateException:
The specified child already has a parent you must call removeChild() ...
最佳答案
您需要使用
feedLayout.removeAllViews();
之前
feedLayout.addView(v);
编辑:
feedLayout = new LinearLayout(this);
feedLayout.setOrientation(LinearLayout.VERTICAL);
//LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = getLayoutInflater().inflate(R.layout.list_feeds, feedLayout, false);
lstFeeds = (ListView) v.findViewById(R.id.listfeeds);
lstFeeds.setAdapter(new FeedsAdapter(this, android.R.layout.simple_list_item_1, lista));
feedLayout.addView(v);