Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Saturday, April 12, 2014 7:17 PM
the solution. Upon some googling, all I got was that I should make sure that my xmlns pointed to http://schemas.android.com/apk/res/android, which I have already confirmed. Furthermore, the Main.axml (Which relates to MainActivity : Activity) has the same LinearLayout declaration as the EntryView.axml and works fine.
Here is my code for my EntryView ListActivity (minus the using directories):
namespace DataInteraction
{
[Activity (Label = "EntryView")]
public class EntryView : ListActivity
{
public string token;
public string email;
public string name;
protected override void OnCreate (Bundle bundle)
{
string[] items;
base.OnCreate (bundle);
SetContentView (Resource.Layout.EntryView);
string holder = Intent.GetStringExtra ("Token");
string[] temp = holder.Split ('|');
token = temp [0];
name = temp [1];
email = temp [2];
TextView lblWelcome = FindViewById<TextView> (Resource.Id.lblWelcomeMsg);
lblWelcome.Text = "Welcome " + name + "!";
items = new string[] { "Test 1", "Test2", "Test 3" };
ListAdapter = new ArrayAdapter<string> (this, Android.Resource.Layout.SimpleListItem1, items);
// Create your application here
}
}
}
And for EntryView.axml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:minWidth="25px"
android:minHeight="25px">
<ListView/>
<TextView
android:text="Welcome!"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/lblWelcomeMsg" />
<ListView
android:id="@+id/lstEntries"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:cacheColorHint="#FFDAFF7F" />
</LinearLayout>
All replies (3)
Saturday, April 12, 2014 7:32 PM
Your EntryView layout has a first child of LinearLayout where you did not specify any attributes. It needs at least layout_width and layout_height, every view specified in a AXML file needs that.
Also if you are using ListActivity your ListView needs to use @android:id/list as ID for one of your ListViews which is going to be the one that will be accesible from the ListActivity as the ListView property.
Saturday, April 12, 2014 7:39 PM
Thank you Cheesebaron! Works gorgeously now. I had previously pulled the "" line out, as I did not recall writing it, but then I received a host of other errors. Code works gorgeously now
Wednesday, August 22, 2018 4:12 AM
@JeffLuetzenberg .I encountered same problem like this . you have a <ListView/> after the parent> <LinearLayout> which does not have any attributes.