I am using spinner to display the list of months.
But do I want to set an image to overlay in months? But I'm setting up any precise solution.
spinner.xml:
& Lt; ImageView Android: id = "@ + id / myimgview" Android: layout_width = "fill_parent" Android: layout_height = "fill_parent" & gt; & Lt; / ImageView & gt; & Lt; / LinearLayout & gt; Your activity class should look like this:
package my.co.home; Import android App Import android.content.Intent; Import android.content.Intent; Importroid.os.Bundle; Import android.view.View; Import android.widget.AdapterView; Import android.widget.ArrayAdapter; Import android.widget.ImageView; Android Import; Spinner; Import android.widget.AdapterView.OnItemSelectedListener; Public category visual activity activity extends to {string [] presidents = {"Jan", "February", "March", "December"}; Spinner S 1; ImageView ivl; /** Called when the activity is first created. * / @Override Public Zero onCreate (bundled savedInstanceState) {super.onCreate (savedInstanceState); // Initialization (new intent (this, spinner activity category)); S1 = (Spinner) Find VVBIID (RID Spinner 1); Ivl = (ImageView) findViewById (R.id.myimgview); ArrayAdapter & LT; String & gt; Adapter = new array adapter & lt; String & gt; (This, Android .R.Let.Simple_spinner_item, presidents); S1.setAdapter (adapter); S1.setOnItemSelectedListener (New item selected selector) {Selected item at public zero (see AdapterView; ART 0, ARB1 View, int arc2, perpendicular RG3) {int index = S 1.get selected intestation ( ); // Depending on the index, you display the image .. For example I have taken // for two indexes (index == 1) ivl.setBackgroundDrawable (getResources (). GetDrawable (R.drawable.images )) And if (index == 2) ivl.setBackgroundDrawable (getResources () .getDrawable (R.drawable.images1));} The public void (adapter sequence & lt ;? selected & Gt; arg0) {}}); }}
Comments
Post a Comment