UPDATE____
Logcat output http://pastie.org/2039452
My application is stopping in the debugger, and then crashing on this line, but it is strange because it has no error information just a green arrow like so...
Any insight on what this arrow means in general would be appreciated...
Here is LayoutStudentList
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
>
<TextView
android:id="#+id/studentHeader"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:textSize="16sp"
android:text="#string/StudentListHeader"
android:layout_alignParentTop="true"
/>
<EditText
android:id="#+id/studentSearch"
android:layout_width="fill_parent"
android:layout_below="#id/studentHeader"
android:padding="10dp"
android:textSize="12sp"
android:editable="true"
android:hint="#string/StudentFilterPlaceholder"
/>
<ListView
android:id="#+id/studentListView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/studentSearch"
android:padding="10dp"
/>
</RelativeLayout>
The problem is almost definitely in my XML somewhere, as when I replace the layout contents with a single textview and set the text it works fine.
The problem is that the studentSearch EditText element in your layout file didn't specify a layout_height attribute. Once you add that in the problem should go away (I verified this locally as well). The error message and accompanying stacktrace would also be visible via the ADB logcat output:
I/dalvikvm( 2083): Ljava/lang/RuntimeException;: Binary XML file line #14: You must supply a layout_height attribute.
What does 'hanging' mean? Like, stopped in the debugger? Crashing?
Shouldn't that be setContentView(), not Set with a capital S? Maybe that's the problem.
Related
I've got a strange problem with FFImageLoading. Compiler don't show any error, but while application is starting on device, there is thrown an exception:
System.NullReferenceException.
Code:
C#
private void setUserImage()
{
ImageService.Instance.Initialize();
imgThunbailUsername = FindViewById<ImageViewAsync>(Resource.Id.imgDisplay);
string url = #"https://lh4.googleusercontent.com/-Lfgi-xEMwuk/VNWoy8EDWcI/AAAAAAAAACk/rwsluNfhSZY/w1486-h832-no/photo.jpg";
ImageService.Instance.LoadUrl(url)
.Retry(3, 200)
.DownSample(60, 60)
.Into(imgThunbailUsername); // compiler points here with an exception
}
XML
<FFImageLoading.Views.ImageViewAsync
android:id="#+id/imgDisplay"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="fitCenter" />
I'd be thankful for any tip, idea, or even another good tool for images in Xamarin.
Okay, I found out what's wrong. XML below is not directly under ViewModel.
<FFImageLoading.Views.ImageViewAsync
android:id="#+id/imgDisplay"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="fitCenter" />
XML over there is called inside
<android.support.design.widget.NavigationView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#android:color/white"
android:id="#+id/nav_view"
app:headerLayout="#layout/drawer_header" <!-- here -->
app:menu="#menu/navmenu" />
</android.support.v4.widget.DrawerLayout>
So in this case I have to call properly view:
View headerLayout = navigationView.InflateHeaderView(Resource.Layout.drawer_header);
and so on use FindViewByIdlike that:
imgThunbailUsername = headerLayout.FindViewById<ImageViewAsync>(Resource.Id.imgDisplay);
So all I need to do is just get a View headerlayout with InflateHeaderView.
pnavk created a Drag and Rearanging listview: http://www.pranavkhandelwal.com/blog/2014/12/26/drag-rearrange-listview-for-xamarin-android Since this is what I need for my app, I am trying to get it to work, but I'm stuck.
I Downloaded the code and setup an empty Android project. Created a xaml file with a LinearLayout and a ListView.
Two problems occur:
hit exception at MainActivity line 25:
System.MissingMethodException: No constructor found for DraggableListView.DraggableListView::.ctor(System.IntPtr, Android.Runtime.JniHandleOwnership).
Resolved this by creating "public DraggableListView(IntPtr javaReference, JniHandleOwnership transfer) : base(javaReference, transfer) { }"
So far so good... but the next one is really puzzling me.
Listview shows no response to long presses, flings, etc. Already found that due to the new constructor init is not called. Every effort of calling the DragggableListView::init leads to crashes in the App.
Can you help out?
Finally I found the solution by myself.
The solution: not use a ListView in the axml, but refer to the DraggableListView in your apps namespace. Note that you must specify the namespace here in lowercase.
appnamespace.ui.android.extensions.DraggableListView
So in my case the axml now look like this:
<?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">
<appnamespace.ui.android.extensions.DraggableListView
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/playerListView" />
</LinearLayout>
While building project an error is shown and build getting failed.
Error redirects to axml file below:
<?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">
<WebView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/webView" />
</LinearLayout>
Error :
C:\Users\Documents\Projects\\\Resources\layout\Main.axml(1,1): Error CS0116:
A namespace cannot directly contain members such as fields or methods (CS0116)
(ABC)
Check the Build Action for the Main.axml file. It should be set to Android Resource but it sounds like it is set to Compile.
Right click the Main.axml file and use the Build Action menu to change this.
I'm making application for android using Visual Studio and Xamarin but I have problem with WebView when I create a WebView and try to see it in android emulator i get an error:
Android.Views.InflateException: Binary XML file line #1: Error inflating class android.webkit.WebView
Anybody knows where is problem?
The Layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="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">
<WebView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/webView1" />
</LinearLayout>
After trying out the Layout xml the compiler throws an error becouse of a semicolon at the end of xmlns:android="schemas.android.com/apk/res/android";. If you remove that the layout should build.
Another thing is that the url in xmlns:android attribute is missing http:// in front of the url. Without that the inflater doesn't understand the attributes correctly.
Here is a fixed Layout for you
<?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">
<WebView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/webView1" />
</LinearLayout>
I'm working on an application for the Android OS using Android Mono so I can program it in C#. All things are working well except for this one issue I am getting.
Basically, I have a sample code that changes the text of a button on every click. I tried to modify the sample code so that instead of changing the button, it changes the text of an xml textview object and, upon getting this error, I replaced it with an edittext object. I replaced it because it seemed common sense that editing an edittext would be easier than a textview.
Anywho, I got the same error at the same place. Whenever I try to change the textview.text or the edittext.text, the program freezes up and I get the error 'Unknown Member".
Here is the C# portion of the code:
Button ampButton = FindViewById<Button>(Resource.Id.CurrentButton);
ampButton.Click += delegate
{
SetContentView(Resource.Layout.AmpScreen);
Button ampButton2 = FindViewById<Button>(Resource.Id.CurrentButtonamp);
EditText ampData = FindViewById<EditText>(Resource.Id.ampdata);
ampButton2.Click += delegate
{
ampButton2.Text = string.Format("{0} clicks!", count2++);
ampData.Text = ampButton2.Text;
//string temp = Convert.ToString(count2) + " clicks!";
//ampData.Text=temp;
//count2++;
};
};
Here are the XML sections that are affected:
From the Main.xml:
<Button
android:id="#+id/CurrentButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/Amp"
/>
From the AmpScreen.xml:
<?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"
>
<ImageView id="#+id/ampImage"
android:layout_width="50px"
android:layout_height="50px"
android:layout_gravity="center"
android:src="#drawable/amp"/>
<EditText id="#+id/ampdata"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Loading"/>
<Button
android:id="#+id/CurrentButtonamp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Re-scan"
/>
<Button
android:id="#+id/homeButtonamp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Back"
/>
</LinearLayout>
Looks like a simple issue with your xml.
In your AmpScreen.xml on the EditText element:
id="#+id/ampdata"
should be:
android:id="#+id/ampdata"