Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何将ArrayList的值设置为多行文本视图_Android_Arraylist_Textview - Fatal编程技术网

Android 如何将ArrayList的值设置为多行文本视图

Android 如何将ArrayList的值设置为多行文本视图,android,arraylist,textview,Android,Arraylist,Textview,我这里有个问题。我有一个ArrayList,它显示了Google的位置。我想将ArrayList值设置为Textview。但是当google place的地址很长时,textview就不会显示完整的地址。我想在文本视图的下一行显示完整地址。 下面是示例代码 private List<Address> getLocationInfo(String address) { List<Address> addrs = new ArrayList<Address>(

我这里有个问题。我有一个ArrayList,它显示了Google的位置。我想将ArrayList值设置为Textview。但是当google place的地址很长时,textview就不会显示完整的地址。我想在文本视图的下一行显示完整地址。 下面是示例代码

private List<Address> getLocationInfo(String address) {

 List<Address> addrs = new ArrayList<Address>();
            String query = "http://maps.google.com/maps/api/geocode/json?address=" +   address.replaceAll(" ","%20")
                    +"&components=country:"+appprefs.getString(Utils.CLIENT_COUNTRYCODE, "")+ "&sensor=false";
            Address addr = null;
            HttpClient client = new DefaultHttpClient();
            HttpGet httpGet = new HttpGet(query);

            HttpResponse response;
            StringBuilder stringBuilder = new StringBuilder();
私有列表getLocationInfo(字符串地址){
List addrs=new ArrayList();
字符串查询=”http://maps.google.com/maps/api/geocode/json?address=+地址.replaceAll(“,“%20”)
+“&components=country:”+appprefs.getString(Utils.CLIENT\u COUNTRYCODE),“+”&sensor=false”;
地址addr=null;
HttpClient=new DefaultHttpClient();
HttpGet HttpGet=新的HttpGet(查询);
HttpResponse响应;
StringBuilder StringBuilder=新的StringBuilder();
xml代码

 <?xml version="1.0" encoding="utf-8"?>
 <TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/textAutoComplete"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical|left"
android:padding="5dp" />

使用TextView的singleLine属性并将其设置为false

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/textView1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:singleLine="false" />

如果您在TextView中输入的文本较短,它将不会自动扩展到n行。如果您希望TextView始终有n行,而不管其中的文本长度如何,请设置android:lines属性:

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/textView1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:singleLine="false"
    android:maxLines="MAX_NUMBER_OF_LINES_YOU_WANT"
    android:lines="NUMBER_OF_LINES_YOU_WANT" />

Patle检查此链接,这是我创建的聊天室,加入。同时接受其他用户提供的答案,这将增加你在堆栈溢出方面的分数。因为你需要至少20个声誉才能在创建的聊天室中聊天。阅读消息后回复我。