Problem with casting rom EditTextPreference

Put your problem here if it does not fit any of the other categories.

Problem with casting rom EditTextPreference

Postby rootman » Tue Apr 10, 2012 4:04 pm

Hi, I receive ClassCastException when I try to cast from EditTextPreference to object of my class that extends EditTextPreference. This is my class.

Code: Select all
public class EditPreference extends EditTextPreference{
   
   public EditPreference(Context context,AttributeSet attrs,int defStyle ){
      super(context,attrs,defStyle);
      // TODO Auto-generated constructor stub
   }
   
   public EditPreference(Context context,AttributeSet attrs) {
      super(context,attrs);
      // TODO Auto-generated constructor stub
   }
   
   public EditPreference(Context context) {
      super(context);
      // TODO Auto-generated constructor stub
   }

   @Override
   public void onClick(DialogInterface dialog, int which) {
      // TODO Auto-generated method stub
      super.onClick(dialog, which);
      
      switch(which){
         case DialogInterface.BUTTON_POSITIVE:
            break;
         
         case DialogInterface.BUTTON_NEGATIVE:
            break;
      }
   }
   

Code: Select all
private EditTextPreference edp;
private EditPreference ed;

In second line i receive exception

Code: Select all
edp = (EditTextPreference) findPreference("broadcasting");
ed = (EditPreference)edp;


Any suggestion how to solve this problem ?
rootman
Once Poster
Once Poster
 
Posts: 1
Joined: Wed Jan 04, 2012 6:30 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: MSNbot Media and 29 guests