2014-01-18 24 views
1

在Xamarin中,如何获取当前版面,以便从版面中删除子版?从版面中删除子版

这里是我的代码:

SetContentView (Resource.Layout.AutoLinkTextView); 

TextView Email = (TextView)FindViewById(Resource.Id.TextViewEmail); 
Email.Text = "Test Email of [email protected]"; 

TextView Phone = (TextView)FindViewById(Resource.Id.TextViewPhone); 
Phone.Text = "Test Phone of 0800 64 64 64"; 

TextView Web = (TextView)FindViewById(Resource.Id.TextViewWeb); 
Web.Text = "Test Address of http://www.google.com" + "\n" + "Test Address of http://www.stackoverflow.com"; 

在我AutoLinkTextView布局我有以下ID的TextView的,我希望从布局中删除:

android:id="@+id/TextViewMap" 

我可以请有一定的帮助去做这个?

在此先感谢

编辑

我能有一些帮助的代码?

这里是我的代码:

LinearLayout layout = (LinearLayout)FindViewById (0); 
View ViewToRemove = layout.GetChildAt (1); 
layout.RemoveView (ViewToRemove); 

与上面的代码,没有TextView的对象都显示在所有。

+0

你可以使用removeView()函数。 –

回答

2

首先给一些主布局标识。像:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/linearLayout"> 
//All ur textviews 
</LinearLayout> 

然后,在的onCreate()编写代码:

LinearLayout _linear = (LinearLayout) findViewById(Resource.id.linearLayout); 
TextView textViewMap = (TextView) findViewById(Resource.id.TextViewMap); 
_linear.removeView(textViewMap);