How do you set up the ListView and roll them to Android?



  • Hello! There are two variables:

     outputtitle.add(divElement.getText().toString());   
     outputtext.add(divElement1.getText().toString());
    

    How to put them in one ListView, outputtitle - headline, outputtext - text under the heading, preferably with a picture.
    The whole internet is gone, it's not working.

    I'll try to clarify. For example, there is a code:

        public class MyListActivity extends ListActivity {
        public void onCreate(Bundle icicle) {
            super.onCreate(icicle);
            String[] values = new String[] { "Android", "iPhone", "WindowsMobile",
                    "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X",
                    "Linux", "OS/2" };
            ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
                    android.R.layout.simple_list_item_1, values);
            setListAdapter(adapter);
        }
    
    @Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
        String item = (String) getListAdapter().getItem(position);
        Toast.makeText(this, item + " выбран", Toast.LENGTH_LONG).show();
    }
    

    }

    So, how do I move this to normal Activity?
    And also, for example, I created a listview with two texts (TextView):

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" >

    <TextView
    android:id="@+id/label"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@+id/label"
    android:textSize="20px" >
    </TextView>

    &lt;TextView
        android:id="@+id/label1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@+id/label"
        android:textSize="20px" &gt;
    &lt;/TextView&gt;
    

    </LinearLayout>

    How am I supposed to record, one of them is the following code:

            ArrayAdapter<String> mainadapter1 = (new ArrayAdapter<String>(ChReaderActivity.this, R.layout.list, R.id.label, values1));
    listview.setAdapter(mainadapter1);

    But in an attempt to add the text to the second label, nothing works.
    Thank you.



  • That's how the whole nat went off =

    • http://habrahabr.ru/blogs/android_development/133575/ ♪
    • http://habrahabr.ru/blogs/android_development/133569/

    And in fact, any reference, on request, to the castomization of the list of the Android.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2