Open main XML layout and drop Spinner widget or paste below code:
</LinearLayout>
Now open Your Java File and paste below code:
            
            
Now Run your code...
<LinearLayout xmlns:android="http://schemas.
    android:layout_width="fill_
    android:layout_height="fill_
    android:orientation="vertical"
>
    <Spinner
        android:id="@+id/spinner1"
        android:layout_width="match_
        android:layout_height="wrap_
Now open Your Java File and paste below code:
package sel.listG; //package name
import
android.os.Bundle;
import
android.view.View;
import
android.widget.AdapterView;
import
android.widget.AdapterView.
import
android.widget.ArrayAdapter;
import
android.widget.Spinner;
import
android.widget.Toast;
import
android.app.Activity;
public class MainActivity extends Activity implements
OnItemSelectedListener {
      String values[]={"Select
One","January", "July", "June", "Ravi", "Ravinder", "Abhishek", "Abhinav", "Harkishore", "Hardev"};
      @Override
      protected void onCreate(Bundle
savedInstanceState) {
            super.onCreate(
            setContentView(R.layout.activi
            Spinner
lv=(Spinner)findViewById(R.id.
            ArrayAdapter<?>
adapter=new ArrayAdapter<String>(this, android.R.layout.simple_
//you can left the below one line because it is merging two layout 
            adapter.
            lv.setAdapter(adapter);
            lv.setOnItemSelectedListener(t
      }
      @Override
      public void
onItemSelected(AdapterView<?> a, View v, int pos,long id) 
      {
Toast.makeText(
      }
      @Override
      public void
onNothingSelected(AdapterView<
            // TODO
Auto-generated method stub
      }
 }
Now Run your code...
 
 
  
 
 
 
 
As/a mohsin.i want to get he screen size at runtime. Can u plz help me
ReplyDeletew/a ..like this app https://play.google.com/store/apps/details?id=helper.plus ?
Deletecheck information page and than screen property.
Thanks for replying me.actually i want that every andriod mob support my app having diferrent width 'height.i used defferent methods for it but showing some error..can u plz help me brother?
ReplyDeleteFor this, android gives us multiple folders facility for putting xml according to density. Don't use any method.
DeleteHow can i use this brother?
ReplyDeleteI have button on the top of which i have a te.xtview.the height of button changes on every click but the textview goes here and there.now i want to change the position of textview with the change of hight of bttn.can u plz help me brother
ReplyDeletesir ,could you plz upload source code for spinner with multiple selection option populate from mysql php??
ReplyDelete