I'm trying to create an activity, RateCardActivity, which has a spinner in it. My layout file for RateCardActivity is rate_card. My RateCardActivity looks like the following.
public class RateCardActivity {
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.rate_card);
Spinner spinner = (Spinner) findViewById(R.id.select_city);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
R.array.select_city, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
}
}
The layout file rate_card is:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res/com.olacabs.customer"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#android:color/darker_gray"
android:gravity="center"
android:paddingBottom="4dp"
android:paddingTop="4dp"
android:text="#string/rate_card"
android:textColor="#color/white"
android:textSize="20dp"
custom:customFont="litera_bold.ttf" />
<Spinner
android:id="#+id/select_city"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
The RateCardActivity is called from another activity using an intent (I'm sure there is nothing wrong with that part of the code as when I substitute RateCardActivity with another activity, the application works fine). When I try to open the RateCardActivity in the application in emulator, the application crashes and I got the message "The application has stopped unexpectedly. Please try again later."
I can't seem to understand what I'm doing wrong, and want to know how to correct this?
Improve :public class RateCardActivity extends Activity
and add RateCardActivity to AndroidManifiest.xml
Hi you can use spinner activity by this way, I gave a sample code for the help..
public class MyActivity extends Activity {
public static EditText edtsample;
public static EditText edtchannel;
public static EditText edtencoding;
private static Spinner samplespin;
private static Spinner channelspin;
private static Spinner encodingspin;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.settings);
edtsample = (EditText)findViewById(R.id.audvalue1);
edtchannel = (EditText)findViewById(R.id.chanvalue1);
edtencoding = (EditText)findViewById(R.id.encodingvalue1);
edtchannel.setFocusable(false);
edtchannel.setClickable(false);
edtencoding.setFocusable(false);
edtencoding.setClickable(false)
samplespin = (Spinner) findViewById(R.id.audspinner1);
samplespin.setOnItemSelectedListener(new OnItemSelectedListener() {
#Override
public void onItemSelected(AdapterView<?> parent, View view, int position,
long id) {
edtsample.setText(parent.getItemAtPosition(position).toString());
}
#Override
public void onNothingSelected(AdapterView<?> parent) {
edtsample.setText("");
}
});
channelspin = (Spinner) findViewById(R.id.chanspinner1);
channelspin.setOnItemSelectedListener(new OnItemSelectedListener() {
#Override
public void onItemSelected(AdapterView<?> parent, View view, int position,
long id) {
if(parent.getItemAtPosition(position).equals("CHANNEL_PHONE")){
edtchannel.setText(R.string.chan1);
System.out.println("VALUE OF " +
edtchannel.getEditableText().toString()) ;
}
if(parent.getItemAtPosition(position).equals("CHANNEL_CD")){
edtchannel.setText(R.string.chan2);
System.out.println("VALUE OF " +
edtchannel.getEditableText().toString()) ;
}
if(parent.getItemAtPosition(position).equals("CHANNEL_HD")){
edtchannel.setText(R.string.chan2);
System.out.println("VALUE OF " +
edtchannel.getEditableText().toString()) ;
}
}
#Override
public void onNothingSelected(AdapterView<?> parent) {
edtchannel.setText("");
}
});
**And in XML part you do by this**
<Spinner
android:id="#+id/audspinner1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/audioText1"
android:spinnerMode= "dropdown"
android:entries="#array/sample_array" />
<EditText
android:id="#+id/audvalue1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/audspinner1"
android:hint="Enter Sampling Rate"
android:ems="10" >
Related
So I have been trying to display a list of data from my local mysql server using API calls like getAll,getByID,etc. on the spinner in a drop down style. However when I click on the spinner nothing happens. Here's my code for the passing the data to the spinner:-
public class markAbsentee extends AppCompatActivity implements OnItemSelectedListener{
Button fromDate, toDate, save;
TextView displayFDate, displayTDate;
Spinner genieS;
List genieList;
private Spinner getGenieS;
private List<Genie> getGenieList;
private Button getFromDate;
private Button getToDate;
private Button getSave;
private TextView getDisplayFDate;
private TextView getDisplayTDate;
private DatePickerDialog.OnDateSetListener mDateSetListener, mDateSetListener1;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_mark_absentee);
getGenieS = (Spinner) findViewById(R.id.geniespinner);
getFromDate = (Button) findViewById(R.id.button2);
getToDate = (Button) findViewById(R.id.button3);
getDisplayFDate = (TextView) findViewById(R.id.fromDate);
getDisplayTDate = (TextView) findViewById(R.id.toDate);
new SpinTask().execute();
//I have called the AsyncTask here which contains the get() API
}
#Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
Genie selected = (Genie)parent.getSelectedItem();
Toast.makeText(markAbsentee.this, selected.id + " " + selected.name, Toast.LENGTH_LONG).show();
}
#Override
public void onNothingSelected(AdapterView<?> parent) {
}
class SpinTask extends AsyncTask<Void, Void, List<Genie>>{
private Exception exception;
protected void onPreExecute(){}
#Override
protected List<Genie> doInBackground(Void... voids) {
GenieService genieService = new GenieService();
return genieService.getAll();
}
protected void onPostexecute(List<Genie> genies){
if(genies == null){
new ArrayList<Genie>();
}else {
List<String> rows = genies.stream().map(genie -> getRow(genie)).collect(Collectors.toList());
ArrayAdapter<Genie> adapter = new ArrayAdapter<Genie>(markAbsentee.this, android.R.layout.simple_spinner_item, genies);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
Toast.makeText(markAbsentee.this, "Clicked", Toast.LENGTH_LONG).show();
genieS.setAdapter(adapter);
}
}
private String getRow(Genie g){
return String.format("%s %s", g.name, g.salary);
}
}
}
Here's the layout of the spinner:-
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/bcak"
android:orientation="vertical"
tools:context="com.codionics.geniem.markAbsentee">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="76dp"
android:layout_marginTop="59dp"
android:text="Enter Absentee"
android:textSize="30dp"
android:textColor="#ffff" />
<Spinner
android:id="#+id/geniespinner"
android:layout_width="350dp"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="#+id/textView4"
android:layout_marginStart="20dp"
android:layout_marginTop="27dp"
android:popupBackground="#color/colorPrimary"
android:spinnerMode="dropdown"
android:autofillHints="Select genie" />
</RelativeLayout>
</android.support.constraint.ConstraintLayout>
P.S:- GenieService is the service class for calling the API's. I want to display the name and salary of the person in the spinner drop down list.Thanks in advance for the help.
when you set spinner value it containg only single value like string,integer etc show. when you getting data then it add data into list like below ...
listArray.addAll("Your Value");
then after define array adapter like below and set spinner ..
ArrayAdapter arrayAdapter=new ArrayAdapter(this,android.R.layout.simple_list_item_1,strings);
spinner.setAdapter(arrayAdapter);
then after you called any function on spinner item selection used like below code ...
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
#Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
Toast.makeText(getApplicationContext(),"Hello",0).show();
}
#Override
public void onNothingSelected(AdapterView<?> adapterView) {
}
});
Main activity contains a spinner and a button. MainActivity.java code is as follows.
public class MainActivity extends AppCompatActivity implements LoadNew.VCallback {
public Spinner dropdown;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
dropdown = (Spinner) findViewById(R.id.spinner1);
//Create a list of items for the spinner.
String[] items = new String[]{"select topic", "topic1", "topic2"};
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, items);
dropdown.setAdapter(adapter);
dropdown.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
#Override
public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {
// TODO Auto-generated method stub
String sp1 = String.valueOf(dropdown.getSelectedItem());
if (sp1.contentEquals("select topic")) {
loadFun("");
}
if (sp1.contentEquals("topic1")) {
loadFun("topic1");
}
if (sp1.contentEquals("topic2")) {
loadFun("topic2");
}
}
#Override
public void onNothingSelected(AdapterView<?> parentView){
// TODO Auto-generated method stub
}
});
Button x = (Button) findViewById(R.id.full_screen);
x.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
loadFun("topic2", 0);
}
});
}
public void loadFun(String topicName, int i) {
LoadNew st = new LoadNew(this);
st.display(topicName, i);
}
}
The xml layout for main activity is as follows (activity_main.xml).
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Spinner
android:id="#+id/spinner1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:drawable/btn_dropdown"
android:spinnerMode="dropdown" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="#+id/full_screen"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Full Screen"
style="?android:attr/borderlessButtonStyle"/>
</LinearLayout>
<LinearLayout
android:id="#+id/full_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
</LinearLayout>
</LinearLayout>
</RelativeLayout>
There is another java class LoadNew.java as follows.
public class LoadNew {
public interface VCallback {
//To access methods of MainActivity class
}
public Activity activity;
public LoadNew(Activity _activity) {
this.activity = _activity;
VCallback callerActivity = (VCallback) activity;
}
//Display PDF
public void display(String topicName, int i) {
LinearLayout fullScreen = (LinearLayout) this.activity.findViewById(R.id.full_view);
fullScreen.removeAllViews();//Clear field
LayoutInflater inflater = (LayoutInflater) this.activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.activity_load, null);
if(i ==0) {
this.activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
this.activity.setContentView(view);
}
TextView tv= (TextView) this.activity.findViewById(R.id.tv1);
tv.setText(topicName);
tv.setTextSize(100);
}
}
The activity_load.xml file is as follows.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout> xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:id="#+id/tv1"
android:layout_below="#+id/bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</RelativeLayout>
When an item is selected in the spinner, the corresponding text is displayed in the textview. Upon pressing the button, the textview appears in full screen mode.
Now I want to return to the previous view (by pressing back button or by single tab on screen), i.e., the view before the button was clicked. How can I achieve this? Thanks in advance for the patience and the help.
Simplest would be to have the spinner and the non-fullscreen TextView on one activity and open a second activity with the fullscreen mode on button click.
I'm working on a spinner, and I saw this pic from developer.android.com.
This kind of effect is exactly (The way "Home" shows) what I want, but I don't know how to make Spinner looks like it. Android's default effect makes the spinner looks like a bar which is ugly. Could anyone tell me how to do this?
Try this way
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<Spinner
android:id="#+id/osversions"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp" />
<TextView
android:id="#+id/selVersion"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/osversions"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp" />
</RelativeLayout>
Activity
public class MainActivity extends Activity implements OnItemSelectedListener {
Spinner spinnerOsversions;
TextView selVersion;
private String[] state = { "Cupcake", "Donut", "Eclair", "Froyo",
"Gingerbread", "HoneyComb", "IceCream Sandwich", "Jellybean",
"kitkat" };
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
System.out.println(state.length);
selVersion = (TextView) findViewById(R.id.selVersion);
spinnerOsversions = (Spinner) findViewById(R.id.osversions);
ArrayAdapter<String> adapter_state = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, state);
adapter_state.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinnerOsversions.setAdapter(adapter_state);
spinnerOsversions.setOnItemSelectedListener(this);
}
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
spinnerOsversions.setSelection(position);
String selState = (String) spinnerOsversions.getSelectedItem();
selVersion.setText("Selected Android OS:" + selState);
}
#Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
}
I have a spinner within alert dialog. I wanted to reduce padding between spinner items and hence I implemented following:
spinner_row.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="30dp"
android:background="#fff" >
<TextView
android:id="#+id/tvCust"
android:layout_width="200dp"
android:layout_height="30dp"
android:gravity="left|center_vertical"
android:textColor="#000"
android:textSize="15sp" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_alignParentRight="true" />
</RelativeLayout>
Activity code contains following:
spinner= (Spinner) dialog.findViewById(R.id.spinner);
String arr[] = { "1", "2", "3" };
ArrayAdapter<String> adapter = new ArrayAdapter<String>(
CameraActivity.this, R.layout.spinner_row, R.id.tvCust,arr);
spinner.setAdapter(adapter);
Now as you can see in below screenshot, radio button is getting displayed on spinner which is actually a part of spinner_row.xml. Note that textview width is 200dp while spinner is only 130dp long, so that radio button should not have been displayed on spinner. How can I remove it?
Also, when I click any of the spinner item, spinner pop-up doesn't get disappeared as expected.(note all 3 check-boxes are checked in spinner items list). setOnItemSelectedListener is not getting called on item click.
Any help appreciated.
Edit 1
As per farrukh's suggestion, I tried his code and following is the result.
I have this
and this
with these code of xml
xml for adapter named spinadapt.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="30dp"
android:background="#fff" >
<TextView
android:id="#+id/tvCust"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_toLeftOf="#+id/radioButton1"
android:gravity="left|center_vertical"
android:textColor="#000"
android:textSize="15sp" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_alignParentRight="true" />
</RelativeLayout>
and main layout named activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/spinner1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:hint="Select item"
android:background="#drawable/spin"/>
</RelativeLayout>
and java code is class named MainActivity.java
public class MainActivity extends Activity
{
Spinner sp;
TextView tv;
String[] counting={"One","Two","Three","Four"};
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
sp=new Spinner(this);
tv=(TextView)findViewById(R.id.spinner1);
tv.setOnClickListener(new OnClickListener()
{
#Override
public void onClick(View v)
{
sp.performClick();
}
});
sp.setAdapter(new Adapter(MainActivity.this, counting));
sp.setOnItemSelectedListener(new OnItemSelectedListener()
{
#Override
public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3)
{
tv.setText(counting[arg2]);
}
#Override
public void onNothingSelected(AdapterView<?> arg0)
{
}
});
}
}
and adapter class named Adapter.java
public class Adapter extends BaseAdapter
{
LayoutInflater inflator;
String[] mCounting;
public Adapter( Context context ,String[] counting)
{
inflator = LayoutInflater.from(context);
mCounting=counting;
}
#Override
public int getCount()
{
return mCounting.length;
}
#Override
public Object getItem(int position)
{
return null;
}
#Override
public long getItemId(int position)
{
return 0;
}
#Override
public View getView(int position, View convertView, ViewGroup parent)
{
convertView = inflator.inflate(R.layout.spinadapt, null);
TextView tv = (TextView) convertView.findViewById(R.id.tvCust);
tv.setText(Integer.toString(position));
return convertView;
}
}
this is working perfect
hope this will help
I have an XML file: my_form.xml (abridged to just show relevant views). The spinner is populated by a string array from strings.xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/LinearLayout01"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<Spinner
android:id="#+id/task"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:entries="#array/task_array"
android:prompt="#string/task" />
<TextView android:id="#+id/addTask"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Add another task"
android:onClick="onClick"
android:clickable="true"/>
</LinearLayout>
</ScrollView>
So I have an activity that displays the xml spinner and text view.
When the text view is clicked I want to add another instance of the same xml spinner and text view, so that a person can add as many tasks as they like.
I dont want a multi-select listView as I am going to have to associate each chosen item/task with other individual methods
Can anyone help me please?
public class MyFormActivity extends FragmentActivity implements
OnClickListener {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.my_form);
final Spinner spinnerTask = (Spinner) findViewById(R.id.task);
ArrayAdapter<CharSequence> adapter_task = ArrayAdapter
.createFromResource(this, R.array.task_array,
android.R.layout.simple_spinner_item);
spinnerTask.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent, View v, int pos,
long row) {
int taskChoice = spinnerTask.getSelectedItemPosition();
SharedPreferences sharedPref = getSharedPreferences("FileName",
0);
SharedPreferences.Editor prefEditor = sharedPref.edit();
prefEditor.putInt("taskChoiceSpinner", taskChoice);
prefEditor.commit();
}
#Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
}
View tvAddTask = (TextView) findViewById(R.id.addTask);
tvAddTask.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
//Here I want add another instance of the spinner and text view above
}
}
Try this
1 - Edit my_form.xml to this
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/LinearLayout01"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
</LinearLayout>
</ScrollView>
2 - Create new layout xml file text_view.xml and put this in it
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Add another task"
android:clickable="true"/>
3 - Create new layout xml file spinner_view.xml and put this in it
<Spinner xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:entries="#array/task_array"
android:prompt="#string/task" />
4 - Edit your code like this
public class MyFormActivity extends FragmentActivity implements OnClickListener {
private LinearLayout linear;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.my_form);
linear = (LinearLayout) findViewById(R.id.LinearLayout01);
addNewView();
}
private void addNewView(){
Spinner spinnerTask = View.inflate(this, R.layout.spinner_view, null);
TextView tvAddTask = View.inflate(this, R.layout.text_view, null);
linear.addView(spinnerTask);
linear.addView(tvAddTask);
spinnerTask.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent, View v, int pos,
long row) {
int taskChoice = pos;
SharedPreferences sharedPref = getSharedPreferences("FileName",
0);
SharedPreferences.Editor prefEditor = sharedPref.edit();
prefEditor.putInt("taskChoiceSpinner", taskChoice);
prefEditor.commit();
}
#Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
}
tvAddTask.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
//Here I want add another instance of the spinner and text view above
addNewView();
}
});
}
}
Hope this helped you.
You could just write a method that would call the spinner and this method would get called in the spinner.setOnItemSelectedListener();