android spinner  text 太长 最后省略("..."),怎么实现Androidspinner省略 

解决方案 »

  1.   

    1、android:singleLine="true"//设置单行,会自动将多余的文字省略2、android:lines="1"         //设置行数,
       android:maxLength="16"    //设置最长字符数,会自动将多余的文字省略
      

  2.   


    ellipsize属性是textview特有的,spinner不能用呀!我也试了
      

  3.   

    你可以通过spinner.setAdapter(BaseAdapter)来设置spinner,然后再BaseAdapter里面来设置textView的属性,android:singleline在java中为textView.setTransformmationMethod
      

  4.   

    自己重写Baseadapter,设置布局,将textview属性设置下即可,下面的效果不知是否是你想要的,就是这样实现的,实现的比较丑
      

  5.   


    这个是布局
                    <Spinner
                        android:id="@+id/questionSpinner"
                        android:layout_width="0dp"
                        android:layout_height="@dimen/editViewSize"
                        android:layout_weight="1"
                        android:animationCache="true"
                        android:background="@drawable/spinner_background"
                        android:drawSelectorOnTop="true"
                        android:paddingLeft="@dimen/baSize"
                        android:prompt="@string/selectquestion"
                        android:spinnerMode="dropdown"
                        android:textColor="#000000"
                        android:textSize="@dimen/slSize" />    <string name="selectquestion">please click on the security problems</string>    <string-array name="question">
            <item>Please click on the security  problems</item>
            <item>Who is your favorite star?</item>
            <item>What is your favorite pet?</item>
            <item>What is your favorite food?</item>
            <item>Which college did you graduate from?</item>
            <item>Which company your first job in?</item>
        </string-array>本来是想着只要修改了selectquestion的内容就可以改变当不点击的时候提示内容,但是没有效果,而是修改了array-》question的地一个item,给影响了默认的提示内容代码中的
            questionSpinner = (Spinner) findViewById(R.id.questionSpinner);
            ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
                    vcontext, R.array.question, R.layout.spinnertext);
            adapter.setDropDownViewResource(android.R.layout.simple_spinner_item);
            questionSpinner.setAdapter(adapter);
            questionSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
                public void onItemSelected(AdapterView<?> parent, View view,
                        int pos, long id) {
                    question = parent.getItemAtPosition(pos).toString();
                    position = pos;
                }            public void onNothingSelected(AdapterView<?> parent) {
                    question = vcontext.getString(R.string.selectquestion)
                           .toString();
                }
            });
      

  6.   


    差不多,能给个具体代码看看吗?

    差不多,能给个具体代码看看吗?

    给个邮箱吧
    [email protected]谢了
      

  7.   


    差不多,能给个具体代码看看吗?

    差不多,能给个具体代码看看吗?

    给个邮箱吧
    [email protected]谢了
    差不多,能给个具体代码看看吗?

    差不多,能给个具体代码看看吗?

    给个邮箱吧
    [email protected]谢了发过去了