Remove text from spinner

前端 未结 3 1857
星月不相逢
星月不相逢 2020-12-21 19:42

I\'m trying to style a spinner. What I currently have is this \"screen1\"

It is EditText followed by <

相关标签:
3条回答
  • 2020-12-21 20:41

    You have to implement your own adapter that sets the title to empty string. This will do:

    private static class CustomAdapter<T> extends ArrayAdapter<String> {
            public CustomAdapter(Context context, int textViewResourceId, String[] objects) {
                super(context, textViewResourceId, objects);
            }
    
            public View getView(int position, View convertView, ViewGroup parent) {
                View view = super.getView(position, convertView, parent);
                TextView textView = (TextView) view.findViewById(android.R.id.text1);
                textView.setText("");
                return view;
            }       
    }
    

    If your spinner has an id R.id.spinner in your layout set the adapter like this:

    Spinner spinner = (Spinner) findViewById(R.id.spinner);
    CustomAdapter<String> adapter = new CustomAdapter<String>(this, 
        android.R.layout.simple_spinner_dropdown_item, new String[] {"Entry 1", "Entry 2"});
    spinner.setAdapter(adapter);
    

    Of course the new String[] part would depend on what you want to display in your spinner or where the content of the spinner origins from.

    0 讨论(0)
  • 2020-12-21 20:43

    I think you should use Android QuickAction Widget.Link

    Its an open source project in GitHub. Instead of Spinner you can use QucikAction. Its very looks attractive.

    enter image description here

    Please go through below link.

    https://github.com/lorensiuswlt/NewQuickAction3D

    0 讨论(0)
  • 2020-12-21 20:44

    Make the string empty with " ". (i.e. two qoutation marks, with a space in the middle.)

    0 讨论(0)
提交回复
热议问题