I have a listview and inside it I have several edit texts. Initially I had a problem with edit text not getting focus when selected for the first time and I was able to solve it with the help of this link
I have one edittext that is multiline which is defined like this
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<EditText
android:inputType="textMultiLine"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@android:color/black"
android:id="@+id/multiLineText" />
</LinearLayout>
in this edit text, whenever the return key is pressed, it loses its focus. A look at the stack trace points to a runtime exception
11-18 11:13:37.675 W/Binder (25836): Caught a RuntimeException from the binder stub implementation.
11-18 11:13:37.675 W/Binder (25836): java.lang.NullPointerException
11-18 11:13:37.675 W/Binder (25836): at android.view.textservice.SpellCheckerSession$SpellCheckerSessionListenerImpl.onGetSentenceSuggestions(SpellCheckerSession.java:430)
11-18 11:13:37.675 W/Binder (25836): at com.android.internal.textservice.ISpellCheckerSessionListener$Stub.onTransact(ISpellCheckerSessionListener.java:61)
11-18 11:13:37.675 W/Binder (25836): at android.os.Binder.execTransact(Binder.java:404)
11-18 11:13:37.675 W/Binder (25836): at dalvik.system.NativeStart.run(Native Method)
I am clueless as to what causes this exception. Any help would be much appreciated.
Edit: Additional code
Main ListView Layout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/newListView"
android:descendantFocusability="beforeDescendants" />
</LinearLayout>
Main Activity
[Activity(Label = "New", MainLauncher = true, ScreenOrientation = ScreenOrientation.Portrait, WindowSoftInputMode=SoftInput.AdjustPan)]
public class NewActivity : Activity
{
ListView newListView;
NewListAdapter source;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.NewView);
newListView = FindViewById<ListView>(Resource.Id.newListView);
var items = GetItems(); // returns list of custom objects
source = new NewListAdapter(this, items);
newListView.Adapter = source;
}
}
Custom Adapter - GetView
public override View GetView(int position, View convertView, ViewGroup parent)
{
var item = this[position];
View view = convertView;
if (view == null)
{
NewItemType type = (NewItemType)GetItemViewType(position);
switch (type)
{
//other items
case (NewItemType.Notes):
view = context.LayoutInflater.Inflate(Resource.Layout.text_input_list_item, null); //layout for the troublesome edit text
break;
}
}
return view;
}