Problem with Spinner with an image and a text

Put your problem here if it does not fit any of the other categories.

Problem with Spinner with an image and a text

Postby AltaisULE » Fri May 09, 2008 6:44 pm

Hi!
I want to put in each row of a Spinner an ImageView and a TextView... I tried to include in a LinearLayout this two objects and add to the ArrayAdapter this LinearLayout but always emulator shows an error..

Somebody knows what con I do?

This is my source code:

******************************************

public class mySpinner extends Activity {

private Bitmap imagen1;

private Spinner spinner;
private LinearLayout layout1= new LinearLayout(this);
private ImageView imv1 = new ImageView(this);
private TextView text1 = new TextView(this);

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setTheme(android.R.style.Theme_Dialog);
setContentView(R.layout.mainActivity);

OrganizationSpinner();
}

private void OrganizationSpinner(){

//***I create a layout in XML with a LinearLayout (id:layout1) with an ImageView and a TextView inside
spinner = (Spinner) this.findViewById(R.id.spinner1);
layout1 = (LinearLayout)this.findViewById(R.id.layout1);

//**I don´t know exactly what parameters I have to put in ArrayAdapter constructor...
ArrayAdapter<LinearLayout> adapter = new ArrayAdapter<LinearLayout>(
this, android.R.layout.simple_spinner_dropdown_item);

adapter.addObject(layout1);

adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);

}
}



Regards
AltaisULE
Freshman
Freshman
 
Posts: 2
Joined: Sat May 03, 2008 10:24 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Exabot [Bot] and 19 guests