Reputation: 385
I have a layout view "PopulatinData.axml" having one control what i am trying is to access layout in my activity class but only "main" layout is accessed in every activity.
Want to DO
this.SetContentView(Resource.Layout.XXXXXX)
//wnat to access PopulatingData layout
PopulatingData.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="PopulateData">
<TextView
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/txtpopulate" />
</LinearLayout>
Please let me know what's the exact way to access the layout aparft from main???
Upvotes: 0
Views: 611
Reputation: 1
Please try below code and see if it solves your issue:
namespace FirstAndroidApp
{
[Activity(Label = "Activity1", MainLauncher = true, Icon = "@drawable/icon")]
public class Activity1 : Activity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
// Create your application here
SetContentView(Resource.Layout.Results);
}
}
}
Upvotes: 0
Reputation: 17580
Do something like this. I am not very sure in Xamarin.
LayoutInflater inflater = (LayoutInflater)this.GetSystemService(Context.LayoutInflaterService);
var layout = inflater.Inflate(Resource.Layout.XXXXXXX, layoutImages) as LinearLayout;
and for finding view-
this.yourview= layout.FindViewById<Button>(...);
Upvotes: 1