当前位置:网站首页>How to set the drop-down arrow in the spinner- How to set dropdown arrow in spinner?
How to set the drop-down arrow in the spinner- How to set dropdown arrow in spinner?
2022-07-05 06:17:00 【Technology feast】
problem :
I tried to set spinner with drop down arrow but i couldn't fix it can anyone help me with this? I tried to set the spinner with the drop-down arrow , But I can't fix it. Can anyone help me ?I have attached the source code. I attached the source code .
my class file: My class file :
import android.os.Bundle; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.EditText; import android.widget.Spinner; import android.widget.AdapterView.OnItemSelectedListener; import android.widget.Toast; public class topup extends Activity { Spinner spinner,spin1,spin2,spin3; EditText ed,ed1; Button btn; List<String> list, list1,list2,list3; private String[] countries_list={"01","02","03","04","05","06","07","08","09","10","11","12"}; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.topup); spinner = (Spinner) findViewById(R.id.spinner1); spin1= (Spinner) findViewById(R.id.spinner2); spin2= (Spinner) findViewById(R.id.spinner3); spin3= (Spinner) findViewById(R.id.spinner4); ed = (EditText) findViewById(R.id.editText3); list = new ArrayList<String>(); list.add(""); list.add("select"); list.add("01"); list.add("02"); list.add("03"); list.add("04"); list.add("05"); list.add("06"); list.add("07"); list.add("08"); list.add("09"); list.add("10"); list.add("11"); list.add("12"); ArrayAdapter<String> adp = new ArrayAdapter<String> (this, android.R.layout.simple_spinner_item, list); //adp.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adp); spinner.setOnItemSelectedListener(new OnItemSelectedListener() { //@Override public void onItemSelected(AdapterView<?> parent, View arg1,int arg2, long arg3) { // TODO Auto-generated method stub String item = spinner.getItemAtPosition(1).toString(); //Toast.makeText(spinner.getContext(), "Selected: " + item, Toast.LENGTH_LONG).show(); String ss=spinner.getSelectedItem().toString(); String } public void onNothingSelected(AdapterView<?> arg0) { // TODO Auto-generated method stub } });
my xml file: my xml file :
<?xml version="1.0" encoding="UTF-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/back1" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".MainActivity" > <LinearLayout android:id="@+id/linearLayout1" android:layout_width="wrap_content" android:layout_height="55dp" android:layout_alignParentLeft="true" android:layout_alignParentRight="true" android:layout_alignParentTop="true" android:layout_marginTop="20dp" android:background="@drawable/red"> <Spinner android:id="@+id/spinner1" android:layout_width="match_parent" android:layout_height="match_parent" android:dropDownWidth="fill_parent" /> </LinearLayout> <EditText android:id="@+id/editText1" android:layout_width="wrap_content" android:layout_height="55dp" android:layout_alignLeft="@+id/linearLayout1" android:layout_alignRight="@+id/linearLayout1" android:layout_below="@+id/linearLayout1" android:layout_marginTop="25dp" android:background="@drawable/red" android:ems="10" android:hint="enter card number" > <requestFocus /> </EditText> <LinearLayout android:id="@+id/linearLayout2" android:layout_width="wrap_content" android:layout_height="55dp" android:layout_alignLeft="@+id/editText1" android:layout_alignRight="@+id/editText1" android:layout_below="@+id/editText1" android:layout_marginTop="33dp" android:orientation="horizontal" android:background="@drawable/red"> <Spinner android:id="@+id/spinner3" android:layout_width="72dp" android:layout_height="wrap_content" /> <Spinner android:id="@+id/spinner2" android:layout_width="72dp" android:layout_height="wrap_content" /> <EditText android:id="@+id/editText2" android:layout_width="22dp" android:layout_height="match_parent" android:layout_weight="0.18" android:ems="10" android:hint="enter cvv" /> </LinearLayout> <LinearLayout android:id="@+id/linearLayout3" android:layout_width="wrap_content" android:layout_height="55dp" android:layout_alignParentLeft="true" android:layout_alignRight="@+id/linearLayout2" android:layout_below="@+id/linearLayout2" android:layout_marginTop="26dp" android:orientation="vertical" android:background="@drawable/red" > </LinearLayout> <Spinner android:id="@+id/spinner4" android:layout_width="15dp" android:layout_height="18dp" android:layout_alignBottom="@+id/linearLayout3" android:layout_alignLeft="@+id/linearLayout3" android:layout_alignRight="@+id/linearLayout3" android:layout_alignTop="@+id/linearLayout3" /> <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentRight="true" android:layout_below="@+id/linearLayout3" android:layout_marginTop="18dp" android:text="Add Amount" android:background="@drawable/buttonsty"/></RelativeLayout>
Solution :
Reference resources : https://stackoom.com/en/question/1Ngu2边栏推荐
- 对for(var i = 0;i < 5;i++) {setTimeout(() => console.log(i),1000)}的深入分析
- Groupbykey() and reducebykey() and combinebykey() in spark
- Appium foundation - use the first demo of appium
- Leetcode array operation
- 1040 Longest Symmetric String
- 1041 Be Unique
- SPI details
- One question per day 1020 Number of enclaves
- MatrixDB v4.5.0 重磅发布,全新推出 MARS2 存储引擎!
- Leetcode-6108: decrypt messages
猜你喜欢
Data visualization chart summary (I)
Redis publish subscribe command line implementation
数据可视化图表总结(一)
Network security skills competition in Secondary Vocational Schools -- a tutorial article on middleware penetration testing in Guangxi regional competition
LeetCode 0107. Sequence traversal of binary tree II - another method
传统数据库逐渐“难适应”,云原生数据库脱颖而出
2021apmcm post game Summary - edge detection
leetcode-6108:解密消息
LaMDA 不可能觉醒吗?
Sqlmap tutorial (1)
随机推荐
Quickly use Amazon memorydb and build your own redis memory database
MIT-6874-Deep Learning in the Life Sciences Week 7
MySQL advanced part 1: triggers
SQLMAP使用教程(一)
Leetcode-6110: number of incremental paths in the grid graph
Usage scenarios of golang context
Sword finger offer II 058: schedule
Simple selection sort of selection sort
WordPress switches the page, and the domain name changes back to the IP address
MySQL advanced part 1: index
Golang uses context gracefully
Overview of variable resistors - structure, operation and different applications
Leetcode-1200: minimum absolute difference
LeetCode-61
MIT-6874-Deep Learning in the Life Sciences Week 7
Appium自动化测试基础 — Appium测试环境搭建总结
【Rust 笔记】15-字符串与文本(上)
Traversal of leetcode tree
【Rust 笔记】16-输入与输出(下)
One question per day 1020 Number of enclaves