I'm having trouble using buttons and programmatically spinners, because onItemSelectedListener doesn't work as it has to do properly. I've been googling and searching in this forum, and even there are some problems related to mine, I can't solve it, because I don't have the Spinner declared in my layout.
Here is my layout:
...<LinearLayout
android:layout_width="wrap_content"
android:layout_height="50dp"
android:orientation="horizontal"
android:background="#010D00"
android:paddingTop="5dp"
android:layout_gravity="center_vertical|center_horizontal">
<Button
android:id="@+id/magic_filter"
android:layout_height="fill_parent"
android:layout_width="80dp"
android:text="Mágico"/>
<Button
android:id="@+id/mision_time_filter"
android:layout_height="fill_parent"
android:layout_width="80dp"
android:text="Tiempo"/>
</LinearLayout>...
Then I do this:
setContentView(R.layout.gig_noloc_list_fragment);
initializeLayout(); // ...(Button) findViewById(R.id.reputation_filter); x4
initializeSpinners();//...magicSpin = new Spinner(this); x4
initializeAdapters();....
magicFil.setOnClickListener(magicListener);
and
private void initializeAdapters() {
magicAdap = new ArrayAdapter<String>(this, R.layout.gig_noloc_filter_spinner_view, getResources().getStringArray(R.array.magicItems));
magicSpin.setAdapter(magicAdap);
magicSpin.setOnItemSelectedListener(magicSListener);
}
and
private OnClickListener magicListener = new OnClickListener() {
@Override
public void onClick(View v) {
magicSpin.performClick();
}
};
and
private OnItemSelectedListener magicSListener = new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2,long arg3) {
Log.v("HELLO", "BYE");
magicFil.setText("HOLA");
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
magicFil.setText("no tira");
}
};
I don't get any of these messages or texts on the screen or log.
Anybody can tell me what's happening?
Thank you in advance.
Do you have a layout height + width assigned to your elements (spinners, etc)? If not, you may not have anything to click.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.