SlidingMenu icon indicating copy to clipboard operation
SlidingMenu copied to clipboard

Keyboard in dialog - runtime crash

Open akex31 opened this issue 13 years ago • 5 comments

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;      
   } 

akex31 avatar Dec 07 '12 18:12 akex31

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 :)

jfeinstein10 avatar Dec 07 '12 18:12 jfeinstein10

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.

akex31 avatar Dec 07 '12 19:12 akex31

What actually is the ClassCastException? Knowing the specific message there would help

jfeinstein10 avatar Dec 07 '12 21:12 jfeinstein10

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.

akex31 avatar Dec 08 '12 08:12 akex31

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.

akex31 avatar Dec 08 '12 10:12 akex31