के बिना एंड्रॉइड में मल्टी चयन स्पिनर मैं इस लिंक https://www.gorecess.com/ पहले स्पिनर के समान चाहता हूं। चेकबॉक्स के साथ एंड्रॉइड में बहु चयन स्पिनर। स्पिनर ड्रॉपडाउन में कैसे। किसी को भी इस सवाल का जवाब पता है ...अलर्टडिअलॉग
उत्तर
मैं कुछ लिंक आप देखने की है कि प्रकार
इस का पालन करने का उल्लेख कर सकते है लिंक
Multi-Select Drop Down List in Android
Spinner with multiple selection in Android
How to Customize Spinner in Android
यह आपकी मदद कर सकते हैं
फंस गया है, क्या कोई भी मदद कर सकता है http://stackoverflow.com/questions/29446088/how-to-get-spinner-values-in-textview/29487383?noredirect=1#comment47175570_29487383 –
https : //github.com/pratikbutani/MultiSelectSpinner –
<com.extra.MultiSelectionSpinner
android:id="@+id/input1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="2dp" />
MultiSelectionSpinner spinner=(MultiSelectionSpinner)findViewById(R.id.input1);
List<String> list = new ArrayList<String>();
list.add("List1");
list.add("List2");
spinner.setItems(list);
अधिक जानकारी के लिए क्लिक करें here
बहु चयन स्पिनर:
की तरह1-, अपने खुद के एक्सएमएल में एक स्पिनर बनाने इस
<Spinner
android:id="@+id/mySpinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginTop="1dp"/>
इस तरह स्पिनर के लिए एक कस्टम dapter 2-बनाएँ:
public class AdapterTagSpinnerItem extends ArrayAdapter<TagListSimpleSearch>
{
private LayoutInflater mInflater;
private List<TagListSimpleSearch> listState;
public Spinner mySpinner = null;
public AdapterTagSpinnerItem(Context context, int resource, List<TagListSimpleSearch> objects, Spinner mySpinner)
{
super(context, resource, objects);
this.listState = objects;
this.mySpinner = mySpinner;
mInflater = LayoutInflater.from(context);
}
@Override
public View getDropDownView(int position, View convertView, ViewGroup parent)
{
return getCustomView(position, convertView, parent);
}
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
return getCustomView(position, convertView, parent);
}
public View getCustomView(final int position, View convertView, ViewGroup parent)
{
String text = "";
final ViewHolder holder;
if (convertView == null)
{
holder = new ViewHolder();
mInflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = mInflater.inflate(R.layout.spinner_item, null, false);
holder.mTextView = convertView.findViewById(R.id.tvSpinnerItem);
convertView.setTag(holder);
}
else
{
holder = (ViewHolder) convertView.getTag();
}
/**
* check position , if position is zero we put space on top of list of spinner
*/
if ((position == 0))
text = oneSpace;
/**
* check position , if position is one we put cross mark before text to show that position used to be for clear all selected items on spinner
*/
else if ((position == 1))
text = " " + String.valueOf((char) crossMarkAroundBox) + " " + listState.get(position).getTagText();
/**
* check position , if position is two we put check mark before text to show that position used to be for select all items on spinner
*/
else if ((position == 2))
text = " " + String.valueOf((char) tikMarkAroundBox) + " " + listState.get(position).getTagText();
/**
* check position , if position is bigger than two we have to check that position is selected before or not and put check mark or dash before text
*/
else
{
if (listState.get(position).isSelected())
{
text = " " + String.valueOf((char) tikMark) + " " + listState.get(position).getTagText();
}
else
{
text = " " + String.valueOf(dash) + " " + listState.get(position).getTagText();
}
}
holder.mTextView.setText(text);
holder.mTextView.setTag(position);
holder.mTextView.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
/**
* if you want open spinner after click on text for first time we have to open spinner programmatically
*/
mySpinner.performClick();
int getPosition = (Integer) v.getTag();
listState.get(getPosition).setSelected(!listState.get(getPosition).isSelected());
notifyDataSetChanged();
/**
* if clicked position is one
* that means you want clear all select item in list
*/
if (getPosition == 1)
{
clearList();
}
/**
* if clicked position is two
* that means you want select all item in list
*/
else if (getPosition == 2)
{
fillList();
}
}
});
return convertView;
}
/**
* clear all items in list
*/
public void clearList()
{
for (TagListSimpleSearch items : listState)
{
items.setSelected(false);
}
notifyDataSetChanged();
}
/**
* select all items in list
*/
public void fillList()
{
for (TagListSimpleSearch items : listState)
{
items.setSelected(true);
}
notifyDataSetChanged();
}
/**
* view holder
*/
private class ViewHolder
{
private TextView mTextView;
}
}
3- अब आप एडाप्टर
public class TagListSimpleSearch {
private String TagId;
private String TagText;
private boolean selected;
public String getTagId() {
return TagId;
}
public void setTagId(String TagId) {
this.TagId = TagId;
}
public String getTagText() {
return TagText;
}
public void setTagText(String tagText) {
TagText = tagText;
}
public boolean isSelected()
{
return selected;
}
public void setSelected(boolean selected)
{
this.selected = selected;
}
}
4-भरने के लिए वस्तु बनाने के लिए है आपकी गतिविधि में स्पिनर एडाप्टर
public static String oneSpace =" ";
public static int tikMark =0X2714;
public static int crossMark =0X2715;
public static int tikMarkAroundBox =0X2611;
public static int crossMarkAroundBox =0X274E;
public static String dash ="-";
private Spinner mySpinner;
mySpinner= (Spinner) findViewById(R.id.mySpinner);
List<TagListSimpleSearch> tagsNames = new ArrayList<>();
TagListSimpleSearch tagSpecific=new TagListSimpleSearch();
tagSpecific.setTagId("0");
tagSpecific.setTagText(oneSpace);
tagsNames.add(tagSpecific);
tagSpecific=new TagListSimpleSearch();
tagSpecific.setTagId("1");
tagSpecific.setTagText("select All Items");
tagsNames.add(tagSpecific);
tagSpecific=new TagListSimpleSearch();
tagSpecific.setTagId("2");
tagSpecific.setTagText("remove All Items");
tagsNames.add(tagSpecific);
tagSpecific=new TagListSimpleSearch();
tagSpecific.setTagId("0");
tagSpecific.setTagText("Item 0");
tagsNames.add(tagSpecific);
tagSpecific=new TagListSimpleSearch();
tagSpecific.setTagId("1");
tagSpecific.setTagText("Item 1");
tagsNames.add(tagSpecific);
tagSpecific=new TagListSimpleSearch();
tagSpecific.setTagId("2");
tagSpecific.setTagText("Item 2");
tagsNames.add(tagSpecific);
tagSpecific=new TagListSimpleSearch();
tagSpecific.setTagId("3");
tagSpecific.setTagText("Item 3");
tagsNames.add(tagSpecific);
final AdapterTagSpinnerItem adapterTagSpinnerItem = new AdapterTagSpinnerItem(this, 0, tagsNames,mySpinner);
mySpinner.setAdapter(adapterTagSpinnerItem);
आपके उत्तर के लिए धन्यवाद, मुझे विश्वास है कि यह इस पोस्ट पर सबसे अच्छा जवाब है, हालांकि अंडररेड। अंततः एक उत्तर जो लाइब्रेरी पर आधारित नहीं है या आपको किसी अन्य ब्लॉग पोस्ट पर नहीं लाता है। –
- 1. अलर्टडिअलॉग
- 2. एकाधिक अलर्टडिअलॉग
- 3. एंड्रॉइड अलर्टडिअलॉग बाएं
- 4. डिफ़ॉल्ट अलर्टडिअलॉग प्रोग्रामेटिक
- 5. संवाद या अलर्टडिअलॉग
- 6. अलर्टडिअलॉग इनपुट टेक्स्ट
- 7. अलर्टडिअलॉग शीर्षक कैसे प्राप्त करें?
- 8. एंड्रॉइड - कस्टम अलर्टडिअलॉग पृष्ठभूमि रंग
- 9. कस्टम व्यू के साथ अलर्टडिअलॉग
- 10. एंड्रॉइड अलर्टडिअलॉग शीर्षक पृष्ठभूमि रंग
- 11. अलर्टडिअलॉग 'हेडर' पर कस्टम डायलॉग 'हेडर' बदलें
- 12. अलर्टडिअलॉग के आइटम प्रदर्शित नहीं होते
- 13. अलर्टडिअलॉग को बंद करने से खोज बटन कैसे रखें?
- 14. सरल अलर्टडिअलॉग पर डायलॉगफ्रैगमेंट का उपयोग करने का लाभ?
- 15. अलर्टडिअलॉग में केंद्र शीर्षक पर कैसे सेट किया गया है?
- 16. अलर्टडिअलॉग के अंदर सिंगल चॉइस आइटम कैसे सेट करें?
- 17. अलर्टडिअलॉग में आइकन किस आकार का होना चाहिए?
- 18. अलर्टडिअलॉग अदृश्य है जब गतिविधि अग्रभूमि पर वापस
- 19. अलर्टडिअलॉग सूची में कस्टम ऑब्जेक्ट्स; डिस्प्ले स्ट्रिंग और फिर वास्तविक मान कैसे प्राप्त करें?
- 20. मैं फ़्लैटबटन पर एक अलर्टडिअलॉग को कैसे खारिज कर सकता हूं?
- 21. रेज़्यूम() याActivityResult() पर बनाए गए मेरे अलर्टडिअलॉग क्यों नहीं दिखाए जाएंगे?
- 22. कार्य पूर्णीकरण स्रोत और खारिज करने का कारण बनता है कि एकाधिक कस्टम अलर्टडिअलॉग
- 23. एंड्रॉइड: अलर्टडिअलॉग में सूची आइटमों के लिए टेक्स्ट रंग कैसे सेट करें
- 24. अलर्टडिअलॉग में नंबरपिकर हमेशा कीबोर्ड सक्रिय करता है। इसे कैसे अक्षम करें?
- 25. एंड्रॉइड: मैं अलर्टडियलॉग चौड़ाई और ऊंचाई, और अलर्टडिअलॉग शैली के बटन को कैसे सेट कर सकता हूं?
- 26. Activity.onCreate (..)
- 27. एंड्रॉइड: सकारात्मक, नकारात्मक, और तटस्थ बटन के बीच अंतर
- 28. एंड्रॉइड होम स्क्रीन में पॉप अप डायलॉग
- 29. स्क्रीन की किसी भी स्थिति में AlertDialog दिखाएँ
- 30. वरीयता स्क्रीन से AlertDialog कैसे खोलें?
आप कस्टम लेआउट का उपयोग कर सकते हैं। – Aniruddha
आपको कोई लिंक पता है बस मुझे – user3793597