• <tfoot id='ZU5CD'></tfoot>
      <legend id='ZU5CD'><style id='ZU5CD'><dir id='ZU5CD'><q id='ZU5CD'></q></dir></style></legend>

        <bdo id='ZU5CD'></bdo><ul id='ZU5CD'></ul>

      <i id='ZU5CD'><tr id='ZU5CD'><dt id='ZU5CD'><q id='ZU5CD'><span id='ZU5CD'><b id='ZU5CD'><form id='ZU5CD'><ins id='ZU5CD'></ins><ul id='ZU5CD'></ul><sub id='ZU5CD'></sub></form><legend id='ZU5CD'></legend><bdo id='ZU5CD'><pre id='ZU5CD'><center id='ZU5CD'></center></pre></bdo></b><th id='ZU5CD'></th></span></q></dt></tr></i><div id='ZU5CD'><tfoot id='ZU5CD'></tfoot><dl id='ZU5CD'><fieldset id='ZU5CD'></fieldset></dl></div>

      1. <small id='ZU5CD'></small><noframes id='ZU5CD'>

        在对话框列表中设置文本样式

        Styling Text in a Dialog List(在对话框列表中设置文本样式)
          <legend id='IdBPs'><style id='IdBPs'><dir id='IdBPs'><q id='IdBPs'></q></dir></style></legend>

            1. <i id='IdBPs'><tr id='IdBPs'><dt id='IdBPs'><q id='IdBPs'><span id='IdBPs'><b id='IdBPs'><form id='IdBPs'><ins id='IdBPs'></ins><ul id='IdBPs'></ul><sub id='IdBPs'></sub></form><legend id='IdBPs'></legend><bdo id='IdBPs'><pre id='IdBPs'><center id='IdBPs'></center></pre></bdo></b><th id='IdBPs'></th></span></q></dt></tr></i><div id='IdBPs'><tfoot id='IdBPs'></tfoot><dl id='IdBPs'><fieldset id='IdBPs'></fieldset></dl></div>
              <tfoot id='IdBPs'></tfoot>
                <tbody id='IdBPs'></tbody>

            2. <small id='IdBPs'></small><noframes id='IdBPs'>

                  <bdo id='IdBPs'></bdo><ul id='IdBPs'></ul>

                  本文介绍了在对话框列表中设置文本样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我使用了此处给出的说明:.

                  I used the instructions given Here: http://developer.android.com/guide/topics/ui/dialogs.html#AddingAList to create a List in a dialog.

                  The problem is I don't seem to find out a way to wrap long text inside the options. [Please see the image below]

                  Please tell me how to do the text wrapping. :(

                  I am using the following code:

                  items= getArrayFromJson(source+"getdetails.php?brand="+bName+"&car="+cName);
                          builder = new AlertDialog.Builder(this);
                          builder.setTitle("Choose Model");
                          builder.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener() {
                              public void onClick(DialogInterface dialog, int item) {
                                  if(items[item].equals("No Options Available")){
                                      dismissDialog(2);
                                  }
                                  else{
                                      model.setText(items[item]);
                                      mName= items[item].toString();
                  
                                      location.setEnabled(true);
                                      dismissDialog(2);
                                  }
                  
                              }
                          });
                          alert = builder.create();
                  
                          return alert;
                  

                  Any help/direction is highly appreciated :)

                  解决方案

                  At first I would create a list layout... something like:

                  list_layout

                      <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                      android:layout_width="match_parent"
                      android:layout_height="match_parent"
                      android:orientation="vertical" >
                  
                       <ListView
                          android:id="@+id/list"
                          android:layout_width="fill_parent"
                          android:layout_height="wrap_content"
                          android:divider="#b5b5b5"
                          android:dividerHeight="1dp" />
                   </LinearLayout>
                  

                  Then a simple TextView like:

                  single_item_layout

                   <LinearLayout 
                      xmlns:android="http://schemas.android.com/apk/res/android"
                      android:orientation="horizontal" 
                      android:layout_width="fill_parent"
                      android:layout_height="fill_parent"> 
                  
                       <TextView android:id="@+id/singleItem"
                          android:layout_width="fill_parent"
                          android:layout_height="fill_parent"
                          android:gravity="center_vertical"
                          android:layout_alignParentTop="true"
                          android:layout_alignParentBottom="true"
                          android:textStyle="bold"
                          android:textSize="22dp"
                          android:textColor="#FFFFFF"
                          android:padding="10dp"
                          android:text="blue thingy"
                          android:background="#336699" />
                  
                  </LinearLayout>
                  

                  and a simple main layout:

                  main

                      <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                      xmlns:tools="http://schemas.android.com/tools"
                      android:layout_width="match_parent"
                      android:layout_height="match_parent" >
                  
                      <Button
                          android:id="@+id/button1"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_alignParentBottom="true"
                          android:layout_alignParentLeft="true"
                          android:layout_alignParentRight="true"
                          android:onClick="popUp"
                          android:text="pop dialog list" />
                  
                  </RelativeLayout>
                  

                  lastly a simple main Activity:

                  import java.util.ArrayList;
                  import android.app.Activity;
                  import android.app.Dialog;
                  import android.os.Bundle;
                  import android.view.View;
                  import android.widget.AdapterView;
                  import android.widget.AdapterView.OnItemClickListener;
                  import android.widget.ArrayAdapter;
                  import android.widget.ListView;
                  
                  public class MainActivity extends Activity {
                  
                      @Override
                      public void onCreate(Bundle savedInstanceState) {
                          super.onCreate(savedInstanceState);
                          setContentView(R.layout.main);
                      }
                  
                      public void popUp(View v){
                  
                          // Dummy list:
                          ArrayList<String> dummies = new ArrayList<String>();
                  
                          dummies.add("dumm1");
                          dummies.add("dumm2");
                          dummies.add("dumm3");
                          dummies.add("dumm4");
                          dummies.add("dumm5");
                  
                          final Dialog dialog = new Dialog(MainActivity.this);
                          dialog.setContentView(R.layout.list_layout);
                          dialog.setTitle("List Title");
                          ListView listView = (ListView) dialog.findViewById(R.id.list);
                  
                          ArrayAdapter<String> ad = new ArrayAdapter<String>(this, R.layout.single_item_layout , R.id.singleItem, dummies);
                          listView.setAdapter(ad);
                  
                          listView.setOnItemClickListener(new OnItemClickListener() {
                              @Override
                              public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
                                  //do something on click
                                  dialog.dismiss();
                              }
                          });
                  
                          dialog.show();
                      }   
                  }
                  

                  and that's all.

                  I tried to make that as simple as possible, you can google for ideas to make your list a bit attractive, like here.

                  这篇关于在对话框列表中设置文本样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)
                  How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)
                  Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)
                  Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)
                  How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)
                  How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)
                    <tbody id='YToMy'></tbody>
                    <tfoot id='YToMy'></tfoot>
                      <legend id='YToMy'><style id='YToMy'><dir id='YToMy'><q id='YToMy'></q></dir></style></legend>
                      • <bdo id='YToMy'></bdo><ul id='YToMy'></ul>

                      • <i id='YToMy'><tr id='YToMy'><dt id='YToMy'><q id='YToMy'><span id='YToMy'><b id='YToMy'><form id='YToMy'><ins id='YToMy'></ins><ul id='YToMy'></ul><sub id='YToMy'></sub></form><legend id='YToMy'></legend><bdo id='YToMy'><pre id='YToMy'><center id='YToMy'></center></pre></bdo></b><th id='YToMy'></th></span></q></dt></tr></i><div id='YToMy'><tfoot id='YToMy'></tfoot><dl id='YToMy'><fieldset id='YToMy'></fieldset></dl></div>

                        <small id='YToMy'></small><noframes id='YToMy'>