1

我知道有很多关于带有多行文本的微调器的帖子,但我的问题与这些不同。当微调器第一次打开时,多文本会在微调器中换行。但是当我开始向下滚动时,多行文本视图转到单行。我不知道如何停止滚动禁用多行。

这是我的微调器视图布局

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<TextView
    android:id="@+id/text_name"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:singleLine="false"
    android:ellipsize="marquee"
    android:textSize="20sp" />

</LinearLayout>

更新:这是我的自定义适配器

public class ProjectJsonAdapter extends BaseAdapter {
private Context mContext;
private JSONArray mArray;

public ProjectJsonAdapter(Context context, JSONArray array) {
    mArray = array;
    mContext = context;
}

@Override
public int getCount() {
    return mArray.length();
}

@Override
public Object getItem(int position) {
    return null;
}

@Override
public long getItemId(int position) {
    return position;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        LayoutInflater inflater = LayoutInflater.from(mContext);
        convertView = inflater.inflate(R.layout.combo_dropdown, null);
    }
    TextView myView = (TextView) convertView.findViewById(R.id.text_name);
    JSONObject myObj = mArray.optJSONObject(position);
    String name = myObj.optString("project_name");
    String code = myObj.optString("project_code");
    StringBuilder myBuilder = new StringBuilder();
    myBuilder.append(code);
    myBuilder.append(" ");
    myBuilder.append(name);
    myView.setText(myBuilder);
    return convertView;
}

}

4

0 回答 0