Android : setOnItemSelectedListener make my app Crach

on Tuesday, March 24, 2015


Hi am tring to use the Spinner Item to Select a user name then open a new concersation layout when the client click start chat Button .. i am sure that Button code is correct but my Spinner code is not going well it make my application crash ...



myListView.setOnItemSelectedListener(new OnItemSelectedListener (){

@Override
public void onItemSelected(AdapterView<?> parent, View view,
int pos, long id) {

// An item was selected. You can retrieve the selected item using


name1=parent.getItemAtPosition(pos).toString();
CStart = (Button) findViewById(R.id.Start) ;
CStart.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
open(v);
}
}
);
}
public void onNothingSelected(AdapterView<?> parent) {
// Another interface callback

}
});


and this is the open(v) methode code :



protected void open(View v) {
// TODO Auto-generated method stub
Intent i = new Intent(this ,MainActivity2.class);
i.putExtra("message",name1);
startActivityForResult(i, 1);


}


so can you help me to fix my code????


0 comments:

Post a Comment