прокрутите, чтобы добавить больше элементов в список Android

Вот мой элемент Listview

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

<ImageView
    android:id="@+id/img"
    android:layout_width="30dp"
    android:layout_height="30dp"
    android:paddingLeft="10dp"
    android:paddingRight="10dp"
    android:paddingTop="20dp"
    android:gravity="center_vertical"
    android:background="@drawable/starred" />

<TextView
    android:id="@+id/txt_company"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_toRightOf="@+id/img"
    android:paddingBottom="10dp"
    android:textColor="#25383C"
    android:singleLine="true"
    android:textStyle="bold" 
    android:textSize="16dp" />

<TextView
    android:id="@+id/txt_position"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/txt_company"
    android:layout_toRightOf="@+id/img"
    android:textColor="#25383C"
    android:singleLine="true"
    android:textStyle="bold" 
    android:textSize="16dp" />
<TextView
    android:id="@+id/txt_city"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/txt_position"
    android:layout_toRightOf="@+id/img"
    android:textColor="#25383C"
    android:textStyle="bold" 
    android:singleLine="true"
    android:textSize="16dp" />
<TextView
    android:id="@+id/txt_state"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/txt_city"
    android:layout_toRightOf="@+id/img"
    android:textColor="#25383C"
    android:textStyle="bold" 
    android:singleLine="true"
    android:textSize="16dp" />

   </RelativeLayout>\

а это мой список

<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"
android:background="@drawable/main_bg"
>

<RelativeLayout android:layout_width="fill_parent"
    android:layout_height="47dip" android:layout_alignParentTop="true"
    android:background="@drawable/tab_bar" android:id="@+id/rel_jobDesc">

    <TextView android:layout_width="wrap_content" android:id="@+id/txt_SEARCH_TITLE"
        android:layout_height="wrap_content" android:layout_centerInParent="true"
        android:text="" android:textStyle="bold" android:textSize="20dip"
        android:textColor="#fff"></TextView>
</RelativeLayout>
<ListView
   android:id="@+id/list"
   android:cacheColorHint="#00000000"
   android:layout_marginTop="60dp"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/job_match_bg" >

</ListView>

<Button
    android:id="@+id/btn_more"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:background="@drawable/viewmore"
    android:layout_centerHorizontal="true"/>

 </RelativeLayout>

мой код Java

          Data datadap= new Data(this,company,position,city,state,pass_value,desc_str);
            listView.setAdapter(datadap);

и это мое мнение

 public View getView(int position, View convertView, ViewGroup parent) {
         final String description;
         LayoutInflater mInflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
         View row;
         row=mInflater.inflate(R.layout.list_item, parent,false);
         txtcompany = (TextView) row.findViewById(R.id.txt_company);
         imageView = (ImageView) row.findViewById(R.id.img);
         txtPosition= (TextView) row.findViewById(R.id.txt_position);
         txtCity= (TextView) row.findViewById(R.id.txt_city);
         txtState= (TextView) row.findViewById(R.id.txt_state);
         txtcompany.setText("Company:  "+companyarray[position]);
         txtPosition.setText("Position: "+positonarray[position]);
         txtCity.setText("City: "+cityarray[position]);
         txtState.setText("State: "+statearray[position]);
         imageView.setTag(receiceValueOfAdapter.get(position));
         description= Descarray[position];
         db.openWritableDatabase();
         savedItems=db.getAllData(str_user);
 }

и теперь, как мы можем реализовать вытягивание для обновления списка, мои данные списка поступают с сервера.

Я новичок в разработке Android, пожалуйста, помогите мне, как мы можем разработать

Заранее спасибо. И извините за мой плохой английский.


person Bishnu Kumar    schedule 29.11.2013    source источник
comment
что ты хочешь делать? обьясни подробно...   -  person Looking Forward    schedule 29.11.2013
comment
я хочу, чтобы когда пользователь прокручивал вниз, обновлял список и добавлял новые элементы в список. новый элемент, поступающий с сервера.   -  person Bishnu Kumar    schedule 29.11.2013


Ответы (2)


Позвоните notifyDataSetChanged() на свой адаптер. Вы можете сделать это в потоке и вызывать этот поток через каждые 5 секунд (или как хотите). Вы можете посмотреть этот учебник, чтобы получить более полное представление.

person Looking Forward    schedule 29.11.2013
comment
Я новичок в Android, поэтому у меня нет идеи разработать прокрутку и прокрутку вниз в списке. - person Bishnu Kumar; 29.11.2013

Создайте собственный «PullToRefreshListView», расширив класс ListView, и в XML-макете используйте этот класс.

См. здесь: https://github.com/johannilsson/android-pulltorefresh.git

person AndroidDeveloper    schedule 29.11.2013