Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.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-如何在类似HTML的有序列表中显示项目列表?_Android_User Interface - Fatal编程技术网

Android-如何在类似HTML的有序列表中显示项目列表?

Android-如何在类似HTML的有序列表中显示项目列表?,android,user-interface,Android,User Interface,对安卓来说还是新鲜事 我想将一些数据显示为类似HTML的有序列表(不可操作) 榜样 项目一 项目二 项目三 我觉得我错过了一些明显的东西 谢谢, JD或者使用ListView,在选择某个内容时不执行任何操作,或者使用AlertDialog.Builder并调用setItems,在Select处理程序中不执行任何操作,或者使用WebView并以html格式按顺序创建列表。我想没有默认视图或小部件可以执行此操作。您可以尝试使用ListView或以编程方式进行查看(不过这有点脏) xml: <?

对安卓来说还是新鲜事

我想将一些数据显示为类似HTML的有序列表(不可操作)

榜样

  • 项目一
  • 项目二
  • 项目三
  • 我觉得我错过了一些明显的东西

    谢谢,
    JD

    或者使用ListView,在选择某个内容时不执行任何操作,或者使用AlertDialog.Builder并调用setItems,在Select处理程序中不执行任何操作,或者使用WebView并以html格式按顺序创建列表。

    我想没有默认视图或小部件可以执行此操作。您可以尝试使用ListView或以编程方式进行查看(不过这有点脏)

    xml:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/llMain"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
    
    </LinearLayout>
    
    
    
    活动:

    public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
    
            //Get your main layout from the XML
            LinearLayout llMain = (LinearLayout) findViewById(R.id.llMain);
    
            ArrayList<String> alItems = new ArrayList<String>();
            //Put some example data
            alItems.add("Text1");
            alItems.add("Text2");
            alItems.add("Text3");
    
            for(int i=0; i<alItems.size(); i++){
                //We create a Layout for every item
                LinearLayout ll = new LinearLayout(this);
                ll.setOrientation(LinearLayout.HORIZONTAL);
    
                //A TextView to put the order (ie: 1.)
                TextView tv1 = new TextView(this);
                tv1.setText(i+1 + ". ");
    
                ll.addView(tv1, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 0));
    
                //TextView to put the value from the ArrayList
                TextView tv2 = new TextView(this);
                tv2.setText(alItems.get(i));
    
                ll.addView(tv2, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1));
    
                //Add this layout to the main layout of the XML
                llMain.addView(ll, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 0));
            }
        }
    
    public void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    //从XML获取主布局
    LinearLayout llMain=(LinearLayout)findViewById(R.id.llMain);
    ArrayList alItems=新的ArrayList();
    //举一些例子数据
    alItems.添加(“文本1”);
    alItems.add(“Text2”);
    alItems.add(“Text3”);
    
    对于(inti=0;iThanks,WebView看起来很有趣,问题是(据我所知)我们想要显示的列表每次都会不同-这是一个搜索显示结果界面。很高兴了解WebView-这对我来说是新的。谢谢,这与我自己提出的“肮脏”解决方案非常相似。我同意-这很混乱