I'm trying to pass the strings "año" and "artista" from two spinners to the next activity and I get the value "año" but "artista" is always void. I used this method to get the values in other activity and there it works but here, "artista" is always void. Moreover, I have tried with switch method and without success.
I hope someone helps me and tells me what I'm doing wrong. I read and look for information before ask for help,
This is my code,
public class Buscar extends Activity implements OnItemSelectedListener{
String año;
String artista;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_buscar);
Buscar();
Spinner spinnerBuscarAño = (Spinner) findViewById(R.id.añoSpinner);
String[] añoBuscar = {"1995", "2000", "2005"};
spinnerBuscarAño.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, añoBuscar));
spinnerBuscarAño.setOnItemSelectedListener(this);
Spinner spinnerBuscarArtista = (Spinner) findViewById(R.id.artistaSpinner);
String[] artistaBuscar = {"Michael Jackson", "U2", "Depeche Mode"};
spinnerBuscarArtista.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, artistaBuscar));
spinnerBuscarArtista.setOnItemSelectedListener(this);
}
/*
public void onItemSelected(AdapterView<?> parent, View view,int pos, long id) {
switch (parent.getId()) {
case R.id.añoSpinner:
año = parent.getItemAtPosition(pos).toString();
break;
case R.id.artistaSpinner:
artista = parent.getItemAtPosition(pos).toString();
break;
default:
break;
}
}
*/
#Override
public void onItemSelected(AdapterView<?> parent, View v, int position,
long id){
// TODO Auto-generated method stub
Spinner spinner = (Spinner) parent;
if(spinner.getId() == R.id.añoSpinner)
{
año = parent.getItemAtPosition(position).toString();
}
else if(spinner.getId() == R.id.artistaSpinner)
{
artista = parent.getItemAtPosition(position).toString();
}
}
#Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
public void Buscar() {
Button buttonBuscar = (Button) findViewById(R.id.buscar);
buttonBuscar.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View arg0) {
Toast.makeText(getApplicationContext(),artista, Toast.LENGTH_SHORT).show();
Intent intentBuscar = new Intent(Buscar.this, ListadoMusica.class);
intentBuscar.putExtra("myaño", año);
intentBuscar.putExtra("myartista", artista);
startActivity(intentBuscar);
}
});
}
}
If someone can help me,
Thanks in advance,
Possibly you are trying to catch a string of intent with another name.
Try this code:
SpinnerTest.java
public class SpinnerTest extends Activity implements AdapterView.OnItemSelectedListener {
String year;
String artist;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.spinner_activity);
Spinner spinnerYear = (Spinner) findViewById(R.id.spinner1);
final String[] years = {"1995", "2000", "2005"};
spinnerYear.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, years));
spinnerYear.setOnItemSelectedListener(this);
Spinner spinnerArtists = (Spinner) findViewById(R.id.spinner2);
final String[] artists = {"Michael Jackson", "U2", "Depeche Mode"};
spinnerArtists.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, artists));
spinnerArtists.setOnItemSelectedListener(this);
Button btnSearch = (Button) findViewById(R.id.btnSearch);
btnSearch.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Intent searchIntent = new Intent(SpinnerTest.this, SearchActivity.class);
searchIntent.putExtra("year", year);
searchIntent.putExtra("artist", artist);
startActivity(searchIntent);
}
});
}
#Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
switch (adapterView.getId()){
case R.id.spinner1:
year = adapterView.getSelectedItem().toString();
Toast.makeText(SpinnerTest.this, year, Toast.LENGTH_LONG).show();
break;
case R.id.spinner2:
artist = adapterView.getSelectedItem().toString();
Toast.makeText(SpinnerTest.this, artist, Toast.LENGTH_LONG).show();
break;
}
}
#Override
public void onNothingSelected(AdapterView<?> adapterView) {
}
}
SearchActivity.java:
public class SearchActivity extends ActionBarActivity {
String year;
String artist;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_receive_spinner_value);
TextView txtYear = (TextView) findViewById(R.id.txtYear);
TextView txtArtist = (TextView) findViewById(R.id.txtArtist);
if(getIntent().hasExtra("year")){
year = getIntent().getStringExtra("year");
txtYear.setText(year);
}
if(getIntent().hasExtra("artist")){
artist = getIntent().getStringExtra("artist");
txtArtist.setText(artist);
}
}
}
It works for me
Related
I want to make an app which collect data based on some Edittexts and two spinners. Then, by clicking a button show all String data in a TextView. I know it may be simple but I wonder how to get the selected Item in spinners and show them near the rest of values.
'''
Spinner shift, permit;
EditText TextHere, TrainNumber, SignalPerson, NavganPerson, DriverPerson;
TextView BigText;
Button SaveButton;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
shift=(Spinner)findViewById(R.id.shift_spinner);
permit=(Spinner)findViewById(R.id.permission_spinner);
TextHere=(EditText)findViewById(R.id.text_here);
TrainNumber=(EditText)findViewById(R.id.train_number);
SignalPerson=(EditText)findViewById(R.id.signal_person);
NavganPerson=(EditText)findViewById(R.id.navgan_person);
DriverPerson=(EditText)findViewById(R.id.driver_person);
SaveButton=(Button) findViewById(R.id.save_btn);
BigText=(TextView)findViewById(R.id.text_text);
ArrayAdapter ShiftSelect = ArrayAdapter.createFromResource(
this,
R.array.shifts,
R.layout.support_simple_spinner_dropdown_item
);
shift.setAdapter(ShiftSelect);
shift.setOnItemSelectedListener(this);
ArrayAdapter PermissionSelect = ArrayAdapter.createFromResource(
this,
R.array.permissions,
R.layout.support_simple_spinner_dropdown_item
);
permit.setAdapter(PermissionSelect);
permit.setOnItemSelectedListener(this);
final String TN = TrainNumber.getText().toString();
final String TH = TextHere.getText().toString();
final String SP = SignalPerson.getText().toString();
final String NP = NavganPerson.getText().toString();
final String DP = DriverPerson.getText().toString();
SaveButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
}
});
}
#Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
Spinner spinner = (Spinner) parent;
if (spinner.getId()==R.id.shift_spinner){
String SHIFT = parent.getSelectedItem().toString();
}
if (spinner.getId()==R.id.permission_spinner){
String PER = parent.getSelectedItem().toString();
}
}
#Override
public void onNothingSelected(AdapterView<?> parent) {
}
'''
I want to pass Item that is selected from public void onItemSelected to onCreate method section to show it in a txetview.
Thanks you.
Try this.
TextView textView;
Spinner spinner;
String SEL_VALUE;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
spinner=(Spinner)findViewById(R.id.shift_spinner);
textView=(TextView)findViewById(R.id.textView);
SEL_VALUE="";
// Create adapter here
spinner.setAdapter(adapter);
spinner.setOnItemSelectedListener(this);
}
#Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
String sel_val = spinner.getSelectedItem().toString();
// Setting selected value to textView.
SEL_VALUE = sel_val;
textView.setText(sel_val);
}
#Override
public void onNothingSelected(AdapterView<?> parent) {
}
I hope this is what you asked for
Spinner shift, permit;
EditText TextHere, TrainNumber, SignalPerson, NavganPerson, DriverPerson;
TextView BigText;
Button SaveButton;
String SHIFT,PER;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
shift=(Spinner)findViewById(R.id.shift_spinner);
permit=(Spinner)findViewById(R.id.permission_spinner);
TextHere=(EditText)findViewById(R.id.text_here);
TrainNumber=(EditText)findViewById(R.id.train_number);
SignalPerson=(EditText)findViewById(R.id.signal_person);
NavganPerson=(EditText)findViewById(R.id.navgan_person);
DriverPerson=(EditText)findViewById(R.id.driver_person);
SaveButton=(Button) findViewById(R.id.save_btn);
BigText=(TextView)findViewById(R.id.text_text);
ArrayAdapter ShiftSelect = ArrayAdapter.createFromResource(
this,
R.array.shifts,
R.layout.support_simple_spinner_dropdown_item
);
shift.setAdapter(ShiftSelect);
shift.setOnItemSelectedListener(this);
ArrayAdapter PermissionSelect = ArrayAdapter.createFromResource(
this,
R.array.permissions,
R.layout.support_simple_spinner_dropdown_item
);
permit.setAdapter(PermissionSelect);
permit.setOnItemSelectedListener(this);
final String TN = TrainNumber.getText().toString();
final String TH = TextHere.getText().toString();
final String SP = SignalPerson.getText().toString();
final String NP = NavganPerson.getText().toString();
final String DP = DriverPerson.getText().toString();
SaveButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
BigText.setText(SHIFT+" "+PER);
}
});
}
#Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
Spinner spinner = (Spinner) parent;
if (spinner.getId()==R.id.shift_spinner){
SHIFT = parent.getSelectedItem().toString();
}
if (spinner.getId()==R.id.permission_spinner){
PER = parent.getSelectedItem().toString();
}
}
#Override
public void onNothingSelected(AdapterView<?> parent) {
}
Try this Out.
TextView textView;
Spinner spinner;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
spinner=(Spinner)findViewById(R.id.shift_spinner);
textView=(TextView)findViewById(R.id.textView);
// Create adapter here
spinner.setAdapter(adapter);
spinner.setOnItemSelectedListener(this);
}
#Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
String sel_val = spinner.getSelectedItem().toString();
// Setting selected value to textView.
textView.setText(sel_val);
}
#Override
public void onNothingSelected(AdapterView<?> parent) {
}
Hi I am trying to make a apps that contains some list item with auto suggestion from a website. but when i Click one of the Item it return only first item related value. But i want only related value from them.
This is my Main Activity:
public class MainActivity extends AppCompatActivity {
ListView vl;
Button b;
// List view
private ListView lv;
// Listview Adapter
ArrayAdapter<String> adapter;
// Search EditText
EditText inputSearch;
// ArrayList for Listview
ArrayList<HashMap<String, String>> news_title;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
vl = (ListView) findViewById(R.id.myList);
b= (Button) findViewById(R.id.addNewbutton);
inputSearch = (EditText) findViewById(R.id.inputSerach);
fetchingData();
b.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
startActivity(new Intent(getApplicationContext(), AddingNews.class));
}
});
}
void fetchingData(){
String myURL = "http://192.168.56.1/android/api/gettingnews.php";
JsonArrayRequest jsonArrayRequest = new JsonArrayRequest(myURL, new Response.Listener<JSONArray>() {
#Override
public void onResponse(JSONArray response) {
final String[] news_title = new String[response.length()];
final String[] news_detail = new String[response.length()];
final String[] news_time = new String[response.length()];
for (int i =0; i < response.length(); i++){
try {
JSONObject jsonObject = (JSONObject) response.get(i);
news_title[i] = jsonObject.getString("title");
news_detail[i] = jsonObject.getString("news");
news_time[i] = jsonObject.getString("time");
} catch (JSONException e) {
e.printStackTrace();
}
}
// vl.setAdapter(new ArrayAdapter(getApplicationContext(), R.layout.mylistview, R.id.textViewforlist, news_title));
// Adding items to listview
adapter = new ArrayAdapter<String>(getApplicationContext(), R.layout.mylistview, R.id.textViewforlist, news_title);
vl.setAdapter(adapter);
inputSearch.addTextChangedListener(new TextWatcher() {
#Override
public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) {
// When user changed the Text
MainActivity.this.adapter.getFilter().filter(cs);
}
#Override
public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,
int arg3) {
// TODO Auto-generated method stub
}
#Override
public void afterTextChanged(Editable arg0) {
// TODO Auto-generated method stub
}
});
vl.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent(MainActivity.this, Details.class);
intent.putExtra("MyTitle", news_title[position]);
intent.putExtra("MyNews", news_detail[position]);
intent.putExtra("MyTime", news_time[position]);
startActivity(intent);
}
});
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
VolleyLog.d("Volley Log", error);
}
});
com.example.forkan.tuntuninews.AppController.getInstance().addToRequestQueue(jsonArrayRequest);
Toast.makeText(getApplicationContext(),"Data Loaded Successfully", Toast.LENGTH_LONG).show();
}
}
and this is My Details: activites;
public class Details extends AppCompatActivity {
TextView title, time, details;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_details);
title = (TextView) findViewById(R.id.mytitle);
time = (TextView) findViewById(R.id.mytime);
details = (TextView) findViewById(R.id.mydetail);
String _title = getIntent().getStringExtra("MyTitle");
String _news = getIntent().getStringExtra("MyNews");
String _time = getIntent().getStringExtra("MyTime");
title.setText(_title);
time.setText(_time+"\n\n");
details.setText(_news);
}
}
How Can i Fix it Please Help me..
i want to take the value in spinner and user press the ok Button and then start new activity from against the value of spinner. The string array is just like that.
public class Menu extends Activity implements View.OnClickListener {
private String[] array_spinner = {"Select Here", "Honda", "Toyota", "Mitibushi"};
private String[] array_spinner01 = {"Select Here", "Civic", "Gli", "Lancer"};
// //private String[] array_spinner02={"1999","2000","2005"};
// Spinner s,s1,s2;
// Button ok;
//#Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
Spinner s, s1;
Button ok;
Object _globalString;
Object _globalString2;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_menu);
s = (Spinner) findViewById(R.id.spinner);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_spinner_dropdown_item, array_spinner);
s.setAdapter(adapter);
s1 = (Spinner) findViewById(R.id.spinner01);
ArrayAdapter<String> adapter1 = new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_spinner_dropdown_item, array_spinner01);
s1.setAdapter(adapter1);
//
// s2=(Spinner)findViewById(R.id.spinner02);
// ArrayAdapter<String> adapter2=new ArrayAdapter<String>(getApplicationContext(),android.R.layout.simple_spinner_dropdown_item,array_spinner02);
// s2.setAdapter(adapter2);
ok = (Button) findViewById(R.id.btn_ok);
ok.setOnClickListener(this);
s.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
_globalString = parent.getItemAtPosition(position);
}
//#Override
public void onNothingSelected(AdapterView<?> parent) {
// TODO Auto-generated method stub
}
});
s1.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
_globalString2 = parent.getItemAtPosition(position);
}
// #Override
public void onNothingSelected(AdapterView<?> parent) {
// TODO Auto-generated method stub
}
});
}
#Override
public void onClick(View v) {
if (v.getId() == R.id.btn_ok) {
if (_globalString.equals("Honda") || _globalString2.equals("Civic")) {
startActivity(new Intent(getApplicationContext(), Civic.class));
} else if (_globalString.equals("Toyota") || _globalString2.equals("Gli")) {
startActivity(new Intent(getApplicationContext(), Toyota.class));
}
}
}
}
please tell me where is my mistake in this code because i stucked and i cant find it
There are many ways to do this, but I would recommend to follow these solution :
First :
save the value of the spinner in a global string variable by declaring a string at the top of your Activity like below :
public class Menu extends Activity implements View.OnClickListener {
Spinner s1, s2;
Button acceptbutton;
String _globalString ;
String _globalString2 ;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Your code ..
Now you need to save the value of your selected field into that string, everytime your spinner changes value :
s1.setOnItemSelectedListener(new OnItemSelectedListener() {
#Override
public void onItemSelected(AdapterView<?> parent, View view,
int position, long id) {
_globalString = parent.getItemAtPosition(position);
}
#Override
public void onNothingSelected(AdapterView<?> parent) {
// TODO Auto-generated method stub
}
});
s.setOnItemSelectedListener(new OnItemSelectedListener() {
#Override
public void onItemSelected(AdapterView<?> parent, View view,
int position, long id) {
_globalString2 = parent.getItemAtPosition(position);
}
#Override
public void onNothingSelected(AdapterView<?> parent) {
// TODO Auto-generated method stub
}
});
Now you can switch activity based on spinner value :
#Override
public void onClick(View v) {
if (v.getId() == R.id.btn_ok) {
if (_globalString.equals("Honda") || _globalString2.equals("Civic")) {
startActivity(new Intent(getApplicationContext(), Civic.class));
} else if (_globalString.equals("Toyota") || _globalString2.equals("Gli")) {
startActivity(new Intent(getApplicationContext(), Toyota.class));
}
}
}
This code is not reading the value from the spinner it's reading only the first value always,
btnResult.setOnClickListener(new View.OnClickListener()
{
final String USN = spnConversions.getSelectedItem().toString();
#Override
public void onClick(View v)
{
Intent i = new Intent(getApplicationContext(), DatabaseResult.class);
i.putExtra("getData",USN.toString());
startActivity(i);
}
});
Why you are using onClickListener for Spinner ? You should use OnItemSelectedListener() for Spinner see the below example code,
public class MySpinnerSelectedListener implements OnItemSelectedListener {
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
String selected = parent.getItemAtPosition(pos).toString();
}
public void onNothingSelected(AdapterView parent) {
// Do nothing.
}
}
Now register listener using following code,
spinner.setOnItemSelectedListener(new MySpinnerSelectedListener());
You can pass it using following code,
// Sending Code
Intent intent = new Intent(getApplicationContext(), DatabaseResult.class);
intent.putextra("getData",USN.toString());
startActivity(intent);
// Receiving code,
String value= getIntent().getStringExtra("getData");
public class SpinnerExample extends Activity
{
Spinner sp;
String text ="";
Button btnResult;
public void onCreate(Bundle savedInstanceState)
{
sp = (Spinner) findViewById(R.id.spinner1);
sp.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent, View arg1, int arg2, long arg3)
{
this.text = parent.getItemAtPosition(pos).toString();
}
public void onNothingSelected(AdapterView<?> arg0)
{
/ TODO Auto-generated method stub
}
});
btnResult = (Button) findViewById(R.id.buttonId);
btnResult.setOnClickListener(new View.OnClickListener()
{
#Override
public void onClick(View v)
{
Intent i = new Intent(getApplicationContext(), DatabaseResult.class);
i.putExtra("getData",this.text);
startActivity(i);
}
});
}
}
try this
int positionitem = spinner.getSelectedItemPosition();
I'm trying to get the position (number) of the spinner when selected to use it in another Activity that will display a different map each time depending on the item selected. when I run the application it crashes. this is the first Activity code:
public class TestProjectActivity extends Activity {
public Spinner spinner1;
public Integer number;
private Button valideButton;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
MySpinner();
valide_button();
}
public void MySpinner() {
final Spinner spinner1 = (Spinner) findViewById(R.id.spinner1);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
this, R.array.num, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner1.setAdapter(adapter);
spinner1.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parentView,
View selectedItemView, int position, long id) {
// Object item = parentView.getItemAtPosition(position);
TestProjectActivity.this.number = spinner1
.getSelectedItemPosition() + 1;
}
public void onNothingSelected(AdapterView<?> arg0) {// do nothing
}
});
}
public void valide_button() {
valideButton = (Button) findViewById(R.id.valide_button);
valideButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent(TestProjectActivity.this,
MetroMapActivity.class);
startActivity(intent);
}
});
}
}
The way to get the selection of the spinner is:
spinner1.getSelectedItemPosition();
Documentation reference:
http://developer.android.com/reference/android/widget/AdapterView.html#getSelectedItemPosition()
However, in your code, the one place you are referencing it is within your setOnItemSelectedListener(). It is not necessary to poll the spinner, because the onItemSelected method gets passed the position as the "position" variable.
So you could change that line to:
TestProjectActivity.this.number = position + 1;
If that does not fix the problem, please post the error message generated when your app crashes.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
bt = findViewById(R.id.button);
spinner = findViewById(R.id.sp_item);
setInfo();
spinnerAdapter = new SpinnerAdapter(this, arrayList);
spinner.setAdapter(spinnerAdapter);
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
#Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
//first, we have to retrieve the item position as a string
// then, we can change string value into integer
String item_position = String.valueOf(position);
int positonInt = Integer.valueOf(item_position);
Toast.makeText(MainActivity.this, "value is "+ positonInt, Toast.LENGTH_SHORT).show();
}
#Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
note: the position of items is counted from 0.
final int[] positions=new int[2];
Spinner sp=findViewByID(R.id.spinner);
sp.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
#Override
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
// TODO Auto-generated method stub
Toast.makeText( arg2....);
}
#Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
if (position ==0) {
if (rYes.isChecked()) {
Toast.makeText(SportActivity.this, "yes ur answer is right", Toast.LENGTH_LONG).show();
} else if (rNo.isChecked()) {
Toast.makeText(SportActivity.this, "no.ur answer is wrong", Toast.LENGTH_LONG).show();
}
}
This code is supposed to select both check boxes.
Is there a problem with it?