![](/img/trans.png)
[英]How to display GetCountryZipCode() in spinner like textview in below program?
[英]How to display textview programmatically like below picture
我想显示如下图所示的文本视图,我正在搜索,最后我从该站点获得了解决方案“ https://github.com/ApmeM/android-flowlayout ”,但我不知道如何使用此视图。
如何使用此显示为我的要求?
尝试以编程方式进行
FlowLayout
inflater = (FlowLayout) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
FlowLayout ll = (FlowLayout) inflater.inflate(R.layout.main, null);
FlowLayout tv = (FlowLayout) inflater.inflate(R.layout.secondlayout, null);
tv.setLayoutParams(new FlowLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
ll.addView(tv);
setContentView(ll);
在布局上像这样使用它
<org.apmem.tools.layouts.FlowLayout
xmlns:f="http://schemas.android.com/apk/res/com.lopply.lopply"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/content3"
android:layout_marginTop="15dp"
android:layout_width="230dp"
android:layout_height="190dp"
android:layout_below="@id/title3"
f:horizontalSpacing="2dp" >
<TextView
android:id="@+id/content3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/label_tip_3"
android:textColor="#5e5e5e"
android:textSize="18dp" />
<TextView
android:id="@+id/lblFacebook"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/label_tip_3_facebook"
android:textColor="#c64d31"
android:textSize="18dp" />
<TextView
android:id="@+id/lblAnd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/label_tip_3_and"
android:textColor="#5e5e5e"
android:textSize="18dp" />
<TextView
android:id="@+id/lblTwitter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/label_tip_3_twitter"
android:textColor="#c64d31"
android:textSize="18dp" />
<TextView
android:id="@+id/lblDot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/label_tip_3_dot"
android:textColor="#5e5e5e"
android:textSize="18dp" />
</org.apmem.tools.layouts.FlowLayout>
<TableLayout android:layout_width="wrap_content"
android:layout_height="wrap_content >
<TableRow android:layout_width="wrap_content"
android:layout_height="wrap_content> <TextView
android:id="@+id/content3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/label_tip_3"
android:textColor="#5e5e5e"
android:textSize="18dp" />
<TextView
android:id="@+id/lblFacebook"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/label_tip_3_facebook"
android:textColor="#c64d31"
android:textSize="18dp" />
<TextView
android:id="@+id/lblAnd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/label_tip_3_and"
android:textColor="#5e5e5e"
android:textSize="18dp" />
</TableRow>
<TableRow android:layout_width="wrap_content"
android:layout_height="wrap_content> <TextView
android:id="@+id/content3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/label_tip_3"
android:textColor="#5e5e5e"
android:textSize="18dp" />
<TextView
android:id="@+id/lblFacebook"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/label_tip_3_facebook"
android:textColor="#c64d31"
android:textSize="18dp" />
<TextView
android:id="@+id/lblAnd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/label_tip_3_and"
android:textColor="#5e5e5e"
android:textSize="18dp" />
</TableRow>
<TableRow android:layout_width="wrap_content"
android:layout_height="wrap_content> <TextView
android:id="@+id/content3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/label_tip_3"
android:textColor="#5e5e5e"
android:textSize="18dp" />
<TextView
android:id="@+id/lblFacebook"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/label_tip_3_facebook"
android:textColor="#c64d31"
android:textSize="18dp" />
<TextView
android:id="@+id/lblAnd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/label_tip_3_and"
android:textColor="#5e5e5e"
android:textSize="18dp" />
</TableRow>
</TableLayout>
在ur包中添加FlowLayout.java类(来自android-flowLayout项目)。 试试这个:
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FlowLayout _flowLayout = new FlowLayout(this);
setContentView(_flowLayout);
TextView _tv1 = new TextView(this);
_tv1.setBackgroundColor(Color.RED);
_tv1.setText("bvfjjjjjjjjjjjjjjjv");
TextView _tv2 = new TextView(this);
_tv2.setBackgroundColor(Color.RED);
_tv2.setText("bvfjjjjjjjjjjjjjjjv");
TextView _tv3 = new TextView(this);
_tv3.setText("bvfjjjjjjjjjjjjjjjv");
TextView _tv4 = new TextView(this);
_tv4.setText("bvfjjjjjjjjjjjjjjjv");
TextView _tv5 = new TextView(this);
_tv5.setText("bvfjjjjjjjjjjjjjjjv");
TextView _tv6 = new TextView(this);
_tv6.setText("bvfjjjjjjjjjjjjjjjv");
_flowLayout.addView(_tv1);
_flowLayout.addView(_tv2);
_flowLayout.addView(_tv3);
_flowLayout.addView(_tv4);
_flowLayout.addView(_tv5);
_flowLayout.addView(_tv6);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.