微调与长文本不工作正常 [英] Spinner with long text not working fine

查看:122
本文介绍了微调与长文本不工作正常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些问题与微调。根据我的日期,我必须添加到的TableRow A 的TextView 的EditText 微调。我的数组必须在微调显示器是有点长。我测试了我的code与短文的数组,它看起来像这样:

I have some problems with the spinner. Depending of my dates, I must add to a TableRow a TextView with an EditText or a Spinner. My array that must be display in Spinner is a little long. I tested my code with an array with short texts, and it looks like this :

下面的一个问题是,微调并不 FILL_PARENT

Here the single problem is that spinner is not fill_parent.

如果我把我的数组微调器,它看起来是这样的:

If I put my array to spinner it looks like this :

在这种情况下,在离心器并不像旋转器和所述的EditText是不可见的任何更多。当我选择了微调,看来这样的观点:

In this case, the spinner doesn't look like a spinner and the EditText is not visible any more. When I choose the spinner, it appears this view :

在这里我需要显示数组中的所有文本。
这是我的code:

Here I need to display all the text of the array. This is my code :

TableRow.LayoutParams lp = new TableRow.LayoutParams(
            TableRow.LayoutParams.FILL_PARENT , TableRow.LayoutParams.WRAP_CONTENT);
tablerow_product[i] = new TableRow(viewToLoad.getContext());
tablerow_product[i].setLayoutParams(lp);

product_spinner[i] = new Spinner(viewToLoad.getContext());
product_spinner[i].setLayoutParams(lp);   product_spinner[i].setBackgroundResource(R.drawable.spinner_selector);
String[] proba={"red","blue"};  //first image is with this test array
ArrayAdapter spinnerArrayAdapter = new ArrayAdapter(viewToLoad.getContext(),  com.Orange.R.layout.my_spinner_textview,spinnerArray);                                     spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_item);
product_spinner[i].setAdapter(spinnerArrayAdapter);
tablerow_product[i].addView(product_spinner[i]);                                            Themes_TableLayout.addView(tablerow_product[i],new TableLayout.LayoutParams(TableRow.LayoutParams.FILL_PARENT,                  TableRow.LayoutParams.WRAP_CONTENT));

和my_spinner_textview.xml:

and my_spinner_textview.xml :

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    style="?android:attr/spinnerItemStyle"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:textColor="@drawable/textorange_selected"
    android:gravity="left"
    android:singleLine="false"
    android:ellipsize="end"/>

谁能帮我解决呢?任何想法是值得欢迎的。先谢谢了。

Can anyone help me to solve it? Any idea is welcome. Thanks in advance.

推荐答案

有关我的问题,我发现这个解决方案:

For my problem I found this solution :

Spinner language = (Spinner) findViewById(com.Orange.R.id.current_language_text);

ArrayAdapter adapter = new ArrayAdapter(this,
                com.Orange.R.layout.my_spinner_textview, languages);
adapter.setDropDownViewResource(com.Orange.R.layout.multiline_spinner_dropdown_item);
language.setAdapter(adapter);

,其中语言是一个的String [] my_spinner_textview.xml 是:

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/textview_spinner"
    style="?android:attr/spinnerItemStyle"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:textColor="@drawable/textorange_selected" 
    android:paddingLeft="5dp"
    android:singleLine="true"
    android:ellipsize="end"
 />

这篇关于微调与长文本不工作正常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆