Android Spinner - Move option left to right -
hello, above current spinner looks like.
i change few small things , need help:
- move app icon left right, "support me" on left, , icon on far right.
- move circle items right left. i'll have circle, , text. example (circle, "rate me").
- i set focus default on "rate me" option, when start spinner selected. want inner circle in green, aka highlighted.
below source code:
string[] items = new string[] { "rate me", "cancel", "exit" }; arrayadapter<string> adapter = new arrayadapter<string>(this, android.r.layout.simple_spinner_dropdown_item, items); new alertdialog.builder(this).settitle("support me") .seticon(r.drawable.ic_launcher) .setadapter(adapter, new dialoginterface.onclicklistener() { @override public void onclick(dialoginterface dialog, int which) { if (which == 0) { rate(); } if (which == 2) { finish(); } dialog.dismiss(); } }).create().show();
thanks help, it's important newbie me.
update: here's want like:
notice default highlight effect on first option. want create effect exactly.
you have create adapter way:
package com.example.test_all; import android.app.activity; import android.content.context; import android.os.bundle; import android.view.layoutinflater; import android.view.view; import android.view.viewgroup; import android.widget.baseadapter; import android.widget.listview; import android.widget.radiobutton; import android.widget.textview; public class mainactivity extends activity { private listview list; string a[] = { "a", "b", "c", "d", "e" }; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); list = (listview) findviewbyid(r.id.listview1); list.setadapter(new listviewadapter(mainactivity.this)); } public class listviewadapter extends baseadapter { private layoutinflater minflater; public listviewadapter(context con) { // todo auto-generated constructor stub minflater = layoutinflater.from(con); } public int getcount() { // todo auto-generated method stub return a.length; } public object getitem(int position) { // todo auto-generated method stub // return product_id1.size(); return position; } public long getitemid(int position) { // todo auto-generated method stub // return product_id1.get(position).hashcode(); return position; } public view getview(final int position, view convertview, viewgroup parent) { // todo auto-generated method stub final listcontent holder; view v = convertview; if (v == null) { v = minflater.inflate(r.layout.custom, null); holder = new listcontent(); holder.name = (textview) v.findviewbyid(r.id.textview1); holder.rad = (radiobutton) v.findviewbyid(r.id.radiobutton1); // holder.total_rate.setonclicklistener(montitleclicklistener1); v.settag(holder); } else { holder = (listcontent) v.gettag(); } holder.name.settext("" + a[position]); return v; } } static class listcontent { textview name; radiobutton rad; } }
custom.xml
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center" android:weightsum="5" android:orientation="horizontal" > <radiobutton android:id="@+id/radiobutton1" android:layout_width="0dp" android:layout_weight="1" android:layout_height="wrap_content" android:text="" /> <textview android:id="@+id/textview1" android:layout_width="0dp" android:layout_weight="4" android:layout_height="wrap_content" android:text="medium text" android:textappearance="?android:attr/textappearancemedium" /> </linearlayout>
for more detail check blog
this link manage radiobutton selection(here code of checkbox take idea code & manage selection)
Comments
Post a Comment