Keyboard in dialog - runtime crash
Hi, I'm still converting my old code to sliding menu. I have a fragment with a custom listview. In this dialog, there is a edittext. When i run my programm and display the dialog, it works, i can see the edittext. if i click on the edittext to get the keyboard, it crashes whith a error relating to the listview : 12-07 19:13:45.176: E/AndroidRuntime(1511): java.lang.ClassCastException;
The code of my alertdialog is at the end of the post. ( i've try it with abs and no slidingmenu and it works).
Any idea ? Thanks.
private int dialogSetValue() {
final AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
LayoutInflater layoutInflater
= (LayoutInflater)getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view=layoutInflater.inflate(R.layout.dialogsetvalue,null);
final EditText input = (EditText)view.findViewById(R.id.editText1);
final TextView textview = (TextView)view.findViewById(R.id.textViewsetvalue);
alert.setPositiveButton("Valider", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
try {
iniList();
} catch (NumberFormatException e) {
e.printStackTrace();
}
} });
alert.setNegativeButton("Annuler",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
dialog.cancel(); } });
alert.setView(view) ;
alert.create();
alert.show();
return 0;
}
This doesn't have to do with SlidingMenu at all. Removing it from the SlidingMenu Issues page. If you want general Android help, please go to StackOverflow :)
Well, my code works with Action bar sherlock and on a classic fragmentactivity. But it doesn't work when the fragment from wich i run it is the front view of slidingmenu. So, i logicaly deduced that there's a issue with combining a dialogfragment + edittext and slidingmenu.
Maybe i'm wrong. i will get my chances in an other forum. thanks.
What actually is the ClassCastException? Knowing the specific message there would help
Well, it appears that i can make my dialog work when i run it from a listfragment incluced in a slidingmenu framework. It's not working when i run it from a fragment with a listview and other stuff inside, in a slidingmenu framework. It works otherwise (outside a slidingmenu framework).
I'm not sure what that means but i will try to understand and keep this forum informed is it's slidingmenu revelent.
ps : to answer your question, the classcastexception comes from a cast to a holder class in my custom adapter for my listview.
Ok, problem solved.
When the keyboard appears, it moves somes buttons in my listview fragment and so it calls the listview adapter with a view argument that's not null. My adapter didn't expected this situation and crashes.
I'm not sure why it happens only in a slidingmenu context.
This post can be closed.
Thanks.