我有一个ListView显示项目一前一后在ListView中
<ListView
android:layout_width="match_parent"
android:divider="@null"
android:dividerHeight="0dp"
android:layout_height="match_parent"
android:id="@+id/listView1"/>
在这里,我将用我的自定义适配器的一些项目。
CustomAdapter adapter = new CustomAdapter(this, myArrayList);
ListView listView = (ListView) findViewById(R.id. listView1);
listView.setAdapter(adapter);
在我的自定义适配器,我还使用自定义布局,其中只有一个textVeiw:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingBottom="8dp"
android:paddingTop="8dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/custom_textView"/>
</LinearLayout>
一切都很好。好好工作。 textView逐行显示文本。 例子:
<TextView>
<TextView>
<TextView>
等..
但是,我不想用线来显示文本行。我想立即显示一个文本。
像:
<TextView><TextView><TextView><TextView><TextView><TextView>
但是,当它达到其父母或设备屏幕的结束,它会采取一种新的线路。
在此先感谢。
只需尝试RecyclerView。它是更好的然后listview ...你可以以垂直或水平或网格显示listitems。 –
我认为你正在寻找像FlowLayout这样的东西。看到这个:http://stackoverflow.com/questions/4474237/how-can-i-do-something-like-a-flowlayout-in-android 此外, 1.您可以摆脱LinearLayout。如果您真的需要这种布局,那么将layout_width更改为“wrap_content”。 2.将TextView的layout_width更改为“wrap_content”,否则将始终采用全宽。 –
@RafiKamal的计算器问题链接是不开放.. –