我知道有很多关于带有多行文字的微调器的帖子,但我的问题与这些不同。首次打开微调器时,多重文本将换行到微调器中的新行。但是,当我开始向下滚动多行文本视图时,转到单行。我无法弄清楚如何停止滚动禁用多线。
这是我对微调器视图的布局
<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;
}
}