ビュー(子供との相対レイアウト)を追加したいViewFlipperがあります。私はAsyncTaskでこれをしようとしています。ここで ViewFlipperでのビューの追加の追加
は、私が使用していますコードです:保護された無効onProgressUpdateでclass LoadData extends AsyncTask<Object, Void, String>
{
RelativeLayout rl_main;
@Override
protected void onPreExecute()
{
super.onPreExecute();
}
@Override
protected String doInBackground(Object... parametros)
{
Cursor cur_channel = db_Helper.sqlDB.query(DatabaseHelper.Channels_TableName, null, null, null, null, null, null);
startManagingCursor(cur_channel);
int index = 0;
while(cur_channel.moveToNext())
{
LayoutInflater inflater = getLayoutInflater();
rl_main = (RelativeLayout) inflater.inflate(R.layout.newslisting,null);
ListView lv_Listing = (ListView) rl_main.findViewById(R.id.id_lv_news_listing);
LazyAdapter newsAdpater = new LazyAdapter(NewsListing.this, channel_id, db_Helper);
lv_Listing.setAdapter(newsAdpater);
lv_Listing.setDividerHeight(0);
TextView tv_channelNumber = (TextView)rl_main.findViewById(R.id.id_tv_ChannelNumber);
if(tv_channelNumber != null)
{
tv_channelNumber.setText("Some Text");
}
TextView tv_channelName = (TextView)rl_main.findViewById(R.id.id_tv_ChannelName);
if(tv_channelName != null)
{
tv_channelName.setText("Some Text");
}
lv_Listing.setOnItemClickListener(new OnItemClickListener()
{
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3)
{
// something on ListItem Click
}
});
publishProgress();
index++;
}
return null;
}
@Override
protected void onProgressUpdate(Void... v)
{
super.onProgressUpdate(v);
try
{
viewFlipper.addView(rl_main); // Here I get the exception, but not on all the views
}
catch (Exception e)
{
// Exception
}
}
@Override
protected void onPostExecute(String result)
{
super.onPostExecute(result);
progressDialog.dismiss();
}
}
(ボイド... V)、私はViewFlipperにビューを追加するとき、私は例外を取得するが、私はこれが表示されませんViewを追加するたびに例外が発生します。例外は次のとおりです。
java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first. in viewflipper