Search Results

Search found 242 results on 10 pages for 'spinner'.

Page 2/10 | < Previous Page | 1 2 3 4 5 6 7 8 9 10  | Next Page >

  • How do you get the selected value of a spinner -- Android

    - by Matthew Hall
    Hi everyone, I'm trying to get the selected items string out of a spinner. So far I've got this: bundle.putString(ListDbAdapter.DB_PRI, v.getText().toString()); This doesn'y work and gives a casting exception (I thought you could cast a view to a widget that inherits it... obviously not!). So how do you get the selected value of a spinner

    Read the article

  • Spinner in Android crashing when visibilty changes while handling OnClick in a button

    - by Dave George
    I have a spinner in UI, which I want to hide when I handle onClick method for a button. But the application is crashing all the time. Is it that I can't use the setVisibility(View.Gone) on spinners (it is not written anywhere). If I comment it out, then application run fine. I am getting NullPointerException and I am using RelativeLayout. Also, can I do this: public void onItemSelected(AdapterView<?> arg0, View view, int pos, long arg3) { // TODO Auto-generated method stub Toast.makeText(SpinnerActivity.this,selected , Toast.LENGTH_SHORT).show(); spinner.setVisibility(View.GONE); } } Spinner code fore reference: itemsCity=getResources().getStringArray(R.array.cities_array); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource( this, R.array.cities_array, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinnerCity.setAdapter(adapter); And here is Button code: private class BtClickListner implements View.OnClickListener{ @Override public void onClick(View v) { essEditText.setVisibility(View.GONE); spinnerCity.setEnabled(false);// Getting exception here // Also tried spinnerCity.setVisibility(View.GONE);// Exception SameBt.setVisibility(View.GONE);// This is same button for which I am handliing event, but it allows me to change tis property at run time. }

    Read the article

  • Spinner setonitemselectedlistener is not called

    - by Gabrielle
    I have a strange problem. I need to do something when an item from spinner is selected. Here is my code : language = (Spinner) findViewById(R.id.current_language_text); ArrayAdapter adapter = new ArrayAdapter(this, com.Orange.R.layout.my_spinner_textview, languages); adapter.setDropDownViewResource(com.Orange.R.layout.multiline_spinner_dropdown_item); language.setAdapter(adapter); language.setSelection(Integer.valueOf(language_id) - 1); language.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) { System.out.println("position "+position); Toast.makeText(Settings.this, "Hello Toast",Toast.LENGTH_SHORT).show(); } @Override public void onNothingSelected(AdapterView<?> parentView) { // your code here } }); The problem is that onItemSelectedListener is not called. I put System.out.println in onItemSelected() but I don't get it in LogCat. I tried with Toast, and I get the same, it doesn't appear. Every time I select an item from spinner, in LogCat I get this warning : Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@2b1dabd0 Any idea why onItemSelectedListener is not called ?

    Read the article

  • How can I manage the height of android spinner items?

    - by rushinge
    I have an android spinner that's populated by a list of strings using an ArrayAdapter and it operates fine, however because of the way the spinner is displayed I'm running into a display height problem with the list items. At first glance it would seem that the ArrayAdapter can use a single layout for displaying options which leads to the problem I'm having. When displaying the current item in the spinner (when the user is not selecting a new item from the list) the spinner pads the text so that the spinner is a reasonable size for clicking on. However when the user taps on it and brings up the list to select a new item, the list items presented are way to small height-wise. If I use an item layout that presents the list items at a reasonable height, then the spinner itself becomes exorbitantly huge due to it's own padding of the list item. Any ideas on how I can manage the height of these two item display modes so that effectively they display with the same height value instead of the spinner height being larger than the list item display height?

    Read the article

  • how to use spinner

    - by corotana
    I am very new to android. I want to use 2 spinners in my application, one shows the countries list, when any country is selected the other spinner should show the list of cities of that country. when city is selected some action is performed. plz help me with some sample code. thanks in anticipation

    Read the article

  • Small ProgressDialog "spinner" for android

    - by user141146
    Hi, I've been able to use the standard "ProgressDialog" for android to show that an indeterminate task is running But I'd like to use the "smaller" progress dialog "spinner" that's used for indeterminate tasks in some of the standard Android applications like the android Market (there's a small spinning circle that's actually integrated into the application window (as opposed to floating on top of it). Does anyone know how to create the smaller progress dialog (or can someone point me in the right direction)? Thanks!

    Read the article

  • Spinner cannot load an integer array?

    - by Adam
    I have an application, which has a Spinner that I want populated with some numbers (4,8,12,16). I created an integer-array object in strings.xml with the items mentioned above, set the entries of the Spinner to the integer-array, and when I run the app I get: 04-19 23:38:48.016: ERROR/AndroidRuntime(10193): java.lang.NullPointerException 04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:355) 04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at android.widget.ArrayAdapter.getView(ArrayAdapter.java:323) 04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at android.widget.AbsSpinner.onMeasure(AbsSpinner.java:198) 04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at android.view.View.measure(View.java:7965) 04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:2989) 04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:888) 04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at android.widget.LinearLayout.measureVertical(LinearLayout.java:350) 04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at android.widget.LinearLayout.onMeasure(LinearLayout.java:278) 04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at android.view.View.measure(View.java:7965) 04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:2989) 04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at android.widget.FrameLayout.onMeasure(FrameLayout.java:245) 04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at android.view.View.measure(View.java:7965) 04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at android.widget.LinearLayout.measureVertical(LinearLayout.java:464) 04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at android.widget.LinearLayout.onMeasure(LinearLayout.java:278) 04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at android.view.View.measure(View.java:7965) 04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:2989) 04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at android.widget.FrameLayout.onMeasure(FrameLayout.java:245) 04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at android.view.View.measure(View.java:7965) 04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at android.view.ViewRoot.performTraversals(ViewRoot.java:763) 04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at android.view.ViewRoot.handleMessage(ViewRoot.java:1632) 04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at android.os.Handler.dispatchMessage(Handler.java:99) 04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at android.os.Looper.loop(Looper.java:123) 04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at android.app.ActivityThread.main(ActivityThread.java:4310) 04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at java.lang.reflect.Method.invokeNative(Native Method) 04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at java.lang.reflect.Method.invoke(Method.java:521) 04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) 04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at dalvik.system.NativeStart.main(Native Method) As soon as I changed the array to a string-array, this works fine. Is this normal? I realize that I can (and will) just convert the string array values to an int, but it seems weird that I have to. Thanks!

    Read the article

  • How to show loading spinner in jQuery?

    - by Edward Tanguay
    In Prototype I can show a "loading..." image with this code: var myAjax = new Ajax.Request( url, {method: 'get', parameters: pars, onLoading: showLoad, onComplete: showResponse} ); function showLoad () { ... } In jQuery, I can load a server page into an element with this: $('#message').load('index.php?pg=ajaxFlashcard'); but how do I attach a loading spinner to this command as I did in Prototype?

    Read the article

  • ActionBar SpinnerAdapter Large Branding followed by selection (spinner)

    - by SatanEnglish
    I'm trying to implement a spinner In the action bar that has brand Name above it. With the ActionBar setListNavigationCallbacks method if possible actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); actionBar.setListNavigationCallbacks(mSpinnerAdapter, null); Can anyone give me an Idea of how to do this? I would put some code here but I have no idea where to begin as I have not managed to find relevant information yet. Edit: Using V4.0

    Read the article

  • Location of Firefox throbber/spinner image

    - by Premasagar
    I'm trying to locate the "throbber" (or "spinner") image used in the Firefox 3.6x chrome to show that a request is being processed: I'm not familiar with the source code structure for Firefox, and a simple search hasn't yielded the answer. Does anyone know which file I'm looking for? (E.g. can you provide a link to the file in the Mercurial repository, or tell me how to find it?).

    Read the article

  • How to show own view in Spinner Widget instead of Text View?

    - by Janusz
    I have a selection for some items using a spinner widget. At the moment the spinner will load a simple Textview and show the name of the item. It is possible to define an own view to show inside the spinner row? I would suspect it being similar to a custom List row. I simply want to show an individual icon left from the spinner text for each item in the list.

    Read the article

  • Android - How to tell is someone has pressed a SPINNER but not changed the visible item in it.

    - by andy_spoo
    I have a spinner, which mostly works. If a user selects one of the items in it, the 'onItemSelected' routine catches it just fine. But if a user clicks the same spinner, but does not change from the already visible item that it's currently displaying, the 'onItemSelected' routine just ignores it, and the logs show:- WARN/InputManagerService(577): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@437948b0 I there anyway to capture someone doing this? The idea is that my spinner contains a list of names, and when a user selects one from the spinner, it gets added to a listview. I could just add another button to get the name from the spinner, but, screen-space is already lacking and I'd rather not add anymore content.

    Read the article

  • how to add item to Spinner's ArrayAdapter?

    - by allen-c
    i had a EditText , a button and a spinner . When click the button , the spinner will add a new item with name you entered in the EditText. But here is the question, my adapter.add() method seems doesn't work...here is my code: public class Spr extends Activity { Button bt1; EditText et; ArrayAdapter<CharSequence> adapter; Spinner spinner; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); bt1 = (Button)this.findViewById(R.id.bt1); et = (EditText)this.findViewById(R.id.et); spinner = (Spinner)this.findViewById(R.id.spr); adapter = ArrayAdapter.createFromResource( this, R.array.planets_array, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); bt1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String temp = et.getText().toString(); adapter.add(temp); adapter.notifyDataSetChanged(); spinner.setAdapter(adapter); } }); spinner.setOnItemSelectedListener(new Spinner.OnItemSelectedListener(){ @Override public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { Toast.makeText(parent.getContext(), "The planet is " + parent.getItemAtPosition(pos).toString(), Toast.LENGTH_LONG).show(); } @Override public void onNothingSelected(AdapterView<?> arg0) { }}); } }

    Read the article

  • Android: How to bind spinner to custom object list?

    - by niko
    Hi, In the user interface there has to be a spinner which contains some names (the names are visible) and each name has its own ID (the IDs are not equal to display sequence). When the user selects the name from the list the variable currentID has to be changed. The application contains the ArrayList Where User is an object with ID and name: public class User{ public int ID; public String name; } What I don't know is how to create a spinner which displays the list of user's names and bind spinner items to IDs so when the spinner item is selected/changed the variable currentID is set to appropriate value. I would appreciate if anyone could show the solution of the described problem or provide any link useful to solve the problem. Thanks!

    Read the article

  • How do you retrieve the array adapter currently set for a spinner? Android OS, Droid

    - by Sean
    Looking to create a menu toggle that switches between two possible arrays for a spinner. For example, if the spinner is set to show array A, then when I press this menu button, I want the spinner to be set to array B. If I press it again, I want it to be set back to array A. I can handle the if/then statements and all, but how do I call the spinner's array adapter? I know how to call its value using getSelectedItemPosition(); but is there a similar method for retrieving WHICH array it is currently set to?

    Read the article

  • Android: How to set the maximum size of a Spinner?

    - by Epaga
    Here is my layout <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:id="@+id/LinearLayout01" android:layout_height="wrap_content"> <Spinner android:text="@+id/AutoCompleteTextView01" android:id="@+id/Spinner01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:width="130dp"></Spinner> <EditText android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/Chapter" android:width="30dp"></EditText> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/TextView01" android:text=":"></TextView> <EditText android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/Verse" android:width="40dp"></EditText> </LinearLayout> I inflate this layout as an AlertDialog's view. But when I pick a large element, the text fields get pushed out to the right. Is there any way to set the maximum size of the spinner so after choosing an element, it shortens the choice with an ellipsis ("...") or something?

    Read the article

  • jQuery UI 1.9 b1 est disponible, cette version intègre trois nouveaux widgets : Menu, Tooltip et Spinner

    jQuery UI 1.9 b1 est disponible Cette version intègre trois nouveaux widgets : Menu, Tooltip et Spinner Annoncée en novembre 2010 et plus officiellement en mars 2011, la refonte complète de jQuery UI est enfin disponible pour vos tests. Comme annoncé lors du démarrage du projet, il s'agit d'une version non rétrocompatible. Cette refonte a nécessité la construction de 8 versions intermédiaires, il y a eu 200 corrections de bugs et 2100 directives de travail. Elle intègre trois nouv...

    Read the article

  • How to give position zero of spinner a prompt value?

    - by Eugene H
    The database is then transferring the data to a spinner which I want to leave position 0 blank so I can add a item to the spinner with no value making it look like a prompt. I have been going at it all day. FAil after Fail MainActivity public class MainActivity extends Activity { Button AddBtn; EditText et; EditText cal; Spinner spn; SQLController SQLcon; ProgressDialog PD; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); AddBtn = (Button) findViewById(R.id.addbtn_id); et = (EditText) findViewById(R.id.et_id); cal = (EditText) findViewById(R.id.et_cal); spn = (Spinner) findViewById(R.id.spinner_id); spn.setOnItemSelectedListener(new OnItemSelectedListenerWrapper( new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { SQLcon.open(); Cursor c = SQLcon.readData(); if (c.moveToPosition(pos)) { String name = c.getString(c .getColumnIndex(DBhelper.MEMBER_NAME)); String calories = c.getString(c .getColumnIndex(DBhelper.KEY_CALORIES)); et.setText(name); cal.setText(calories); } SQLcon.close(); // closing database } @Override public void onNothingSelected(AdapterView<?> parent) { // TODO Auto-generated method stub } })); SQLcon = new SQLController(this); // opening database SQLcon.open(); loadtospinner(); AddBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { new MyAsync().execute(); } }); } public void loadtospinner() { ArrayList<String> al = new ArrayList<String>(); Cursor c = SQLcon.readData(); c.moveToFirst(); while (!c.isAfterLast()) { String name = c.getString(c.getColumnIndex(DBhelper.MEMBER_NAME)); String calories = c.getString(c .getColumnIndex(DBhelper.KEY_CALORIES)); al.add(name + ", Calories: " + calories); c.moveToNext(); } ArrayAdapter<String> aa1 = new ArrayAdapter<String>( getApplicationContext(), android.R.layout.simple_spinner_item, al); spn.setAdapter(aa1); // closing database SQLcon.close(); } private class MyAsync extends AsyncTask<Void, Void, Void> { @Override protected void onPreExecute() { super.onPreExecute(); PD = new ProgressDialog(MainActivity.this); PD.setTitle("Please Wait.."); PD.setMessage("Loading..."); PD.setCancelable(false); PD.show(); } @Override protected Void doInBackground(Void... params) { String name = et.getText().toString(); String calories = cal.getText().toString(); // opening database SQLcon.open(); // insert data into table SQLcon.insertData(name, calories); return null; } @Override protected void onPostExecute(Void result) { super.onPostExecute(result); loadtospinner(); PD.dismiss(); } } } DataBase public class SQLController { private DBhelper dbhelper; private Context ourcontext; private SQLiteDatabase database; public SQLController(Context c) { ourcontext = c; } public SQLController open() throws SQLException { dbhelper = new DBhelper(ourcontext); database = dbhelper.getWritableDatabase(); return this; } public void close() { dbhelper.close(); } public void insertData(String name, String calories) { ContentValues cv = new ContentValues(); cv.put(DBhelper.MEMBER_NAME, name); cv.put(DBhelper.KEY_CALORIES, calories); database.insert(DBhelper.TABLE_MEMBER, null, cv); } public Cursor readData() { String[] allColumns = new String[] { DBhelper.MEMBER_ID, DBhelper.MEMBER_NAME, DBhelper.KEY_CALORIES }; Cursor c = database.query(DBhelper.TABLE_MEMBER, allColumns, null, null, null, null, null); if (c != null) { c.moveToFirst(); } return c; } } Helper public class DBhelper extends SQLiteOpenHelper { // TABLE INFORMATTION public static final String TABLE_MEMBER = "member"; public static final String MEMBER_ID = "_id"; public static final String MEMBER_NAME = "name"; public static final String KEY_CALORIES = "calories"; // DATABASE INFORMATION static final String DB_NAME = "MEMBER.DB"; static final int DB_VERSION = 2; // TABLE CREATION STATEMENT private static final String CREATE_TABLE = "create table " + TABLE_MEMBER + "(" + MEMBER_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + MEMBER_NAME + " TEXT NOT NULL," + KEY_CALORIES + " INT NOT NULL);"; public DBhelper(Context context) { super(context, DB_NAME, null, DB_VERSION); } @Override public void onCreate(SQLiteDatabase db) { db.execSQL(CREATE_TABLE); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // TODO Auto-generated method stub db.execSQL("DROP TABLE IF EXISTS " + TABLE_MEMBER); onCreate(db); } }

    Read the article

  • How to set the size of spinner

    - by Rakesh
    Hi Guys,I want to know how to set the size of spinner.When i added large values to spinner list,the spinner expands and as result it pushes the labelField to the further left. I want to know the how to set the spinner size to be a constant one

    Read the article

  • How to update a TextView on ButtonClick with Spinner(s) values

    - by source.rar
    Hi, I am trying to populate a TextView based on the current selected options in 3 Spinner(s) but cant seem to figure out how to retrieve the selected values from the Spinners to invoke the update function with. Here is my current code (quite messy but I'm just learning Java :)), public class AgeFun extends Activity { private String[] dayNames; private String[] yearArray; private final static int START_YEAR = 1990; private static TextView textDisp; private Button calcButton; private static Spinner spinnerDay, spinnerYear, spinnerMonth; private static ArrayAdapter<?> monthAdapter, dayAdapter, yearAdapter; private int year, month, day; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); year = 2000; month = 1; day = 1; textDisp = (TextView) findViewById(R.id.textView1); calcButton = (Button) findViewById(R.id.button); calcButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { // Perform action on clicks AgeFun.updateAge(year, month, day); } }); // Month spinner spinnerMonth = (Spinner) findViewById(R.id.spinnerFirst); monthAdapter = ArrayAdapter.createFromResource( this, R.array.monthList, android.R.layout.simple_spinner_item); monthAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinnerMonth.setAdapter(monthAdapter); // Day spinner dayNames = new String[31]; for(int i =1; i <= 31; ++i) { dayNames[i-1] = Integer.toString(i); } spinnerDay = (Spinner) findViewById(R.id.spinnerSecond); dayAdapter = new ArrayAdapter<CharSequence>(this, android.R.layout.simple_spinner_item, dayNames); spinnerDay.setAdapter(dayAdapter); // Year spinner yearArray = new String[40]; for(int i =0; i < 40; ++i) { yearArray[i] = Integer.toString(START_YEAR+i); } spinnerYear = (Spinner) findViewById(R.id.spinnerThird); yearAdapter = new ArrayAdapter<CharSequence>(this, android.R.layout.simple_spinner_item, yearArray); spinnerYear.setAdapter(yearAdapter); updateAge(2000,1,1); } private static void updateAge(int year, int month, int day) { Date dob = new GregorianCalendar(year, month, day).getTime(); Date currDate = new Date(); long age = (currDate.getTime() - dob.getTime()) / (1000 * 60 * 60 * 24) / 365; textDisp.setText("Your are " + Long.toString(age) + " years old"); } } Any help with this would be great. TIA

    Read the article

  • Fill spinner from cursor in android

    - by Rickard
    Hi, i have searched for a awnser for this for a while today. It all looks so easy but i never get it to work. I want to fill a spinner with my cursor. I have been trying to use SimpleCursorAdapter for this as a lot of sites say i shall but i never get it to work. Show me just how easy it is :) Thanks for your time! My cursor Cursor cursor = db.query(DATABASE_TABLE_Clients, new String[] {"_id", "C_Name"}, null, null, null, null, "C_Name"); My spinner (Spinner) findViewById(R.id.spnClients); My Code Cursor cursor_Names = SQLData.getClientNames(); startManagingCursor(cursor_Names); String[] columns = new String[] { "C_Name" }; int[] to = new int[] { R.id.txt_Address }; SimpleCursorAdapter mAdapter = new SimpleCursorAdapter(this, android.R.layout.simple_spinner_dropdown_item, cursor_Names, columns, to); Spinner spnClients = (Spinner) findViewById(R.id.spnClients); spnClients.setAdapter(mAdapter);

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10  | Next Page >