创建我创建我的布局有问题。然后点击按钮我想删除以前的布局内容我怎么能这样做,我试过removeView。但它没有为我工作。这里是我的代码空白在Android中的布局包含布局点击
void setDate(){
flightResult=(LinearLayout)findViewById(R.id.flightResultData);
LinearLayout.LayoutParams flightDetailsLayout = new LinearLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
LayoutInflater inflater = (LayoutInflater)getBaseContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
LinearLayout.LayoutParams forUnderLine = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT);
forUnderLine.setMargins(0,0, 0, 0);
flightDetailsLayout.setMargins(0, 40, 0, 0);
for(int i=0;i < 5;i++){
TextView line=new TextView(this);
line.setBackgroundResource(R.layout.shape_line);
line.setLayoutParams(forUnderLine);
if(i!=0){
flightResult.addView(line);
}
LinearLayout flightInformations=(LinearLayout)inflater.inflate(R.layout.flight_details_layout, null);
flightLogo=(ImageView)flightInformations.findViewById(R.id.flightLogo);
flightCompany = (TextView)flightInformations.findViewById(R.id.flightCompany);
flightLogo.setImageResource(R.drawable.airindia);
flightCompany.setText("AirIndia");
flightResult.addView(flightInformations);
}
TextView dummy=new TextView(this);
dummy.setLayoutParams(flightDetailsLayout);
flightResult.addView(dummy);
}
后上创建一个按钮的点击我已经再次调用这个函数,并在当我调用这个那个时候它是附加的结果。我是希望有新的结果点击按钮我要为此做什么请帮助我
而我的xml文件
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_below="@+id/sortFlightLayouts">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:id="@+id/flightResultData"
android:orientation="vertical">
</LinearLayout>
</ScrollView>
你试过了吗? – KOTIOS
在那里我不得不disi我在Android的新点击按钮或在功能 – Developer