Skip to content

Commit

Permalink
change layout
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxwin-z committed May 17, 2012
1 parent b837e86 commit 7a123f5
Show file tree
Hide file tree
Showing 5 changed files with 154 additions and 94 deletions.
8 changes: 7 additions & 1 deletion res/layout/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
android:orientation="vertical" android:background="#f0f0f0">

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />

<me.maxwin.view.XListView
android:id="@+id/xListView"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:cacheColorHint="#00000000">
</me.maxwin.view.XListView>

</LinearLayout>
2 changes: 1 addition & 1 deletion res/layout/xlistview_footer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
android:layout_height="wrap_content" >

<RelativeLayout
android:id="@+id/xlistview_footer"
android:id="@+id/xlistview_footer_content"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp" >
Expand Down
12 changes: 5 additions & 7 deletions res/layout/xlistview_header.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,19 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ff0000"
android:gravity="bottom" >

<RelativeLayout
android:id="@+id/xlistview_header"
android:id="@+id/xlistview_header_content"
android:layout_width="fill_parent"
android:layout_height="60dp" >

<LinearLayout
android:id="@+id/xlistview_header_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center"
android:orientation="vertical" >
android:orientation="vertical" android:id="@+id/xlistview_header_text">

<TextView
android:id="@+id/xlistview_header_hint_textview"
Expand Down Expand Up @@ -44,10 +42,10 @@
</LinearLayout>

<ImageView
android:id="@drawable/xlistview_arrow"
android:id="@+id/xlistview_header_arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@id/xlistview_header_content"
android:layout_alignLeft="@id/xlistview_header_text"
android:layout_centerVertical="true"
android:layout_marginLeft="-35dp"
android:src="@drawable/xlistview_arrow" />
Expand All @@ -56,7 +54,7 @@
android:id="@+id/xlistview_header_progressbar"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignLeft="@id/xlistview_header_content"
android:layout_alignLeft="@id/xlistview_header_text"
android:layout_centerVertical="true"
android:layout_marginLeft="-40dp"
android:visibility="invisible" />
Expand Down
71 changes: 64 additions & 7 deletions src/me/maxwin/XListViewActivity.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,70 @@
package me.maxwin;

import java.util.ArrayList;

import me.maxwin.view.XListView;
import me.maxwin.view.XListView.IXListViewListener;
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.widget.ArrayAdapter;

public class XListViewActivity extends Activity implements IXListViewListener {
private XListView mListView;
private ArrayAdapter<String> mAdapter;
private ArrayList<String> items = new ArrayList<String>();
private Handler mHandler;
private int start = 0;
private static int refreshCnt = 0;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
geneItems();
mListView = (XListView) findViewById(R.id.xListView);
mListView.setPullLoadEnable(true);
mAdapter = new ArrayAdapter<String>(this, R.layout.list_item, items);
mListView.setAdapter(mAdapter);
mListView.setXListViewListener(this);
mHandler = new Handler();
}

private void geneItems() {
for (int i = 0; i != 20; ++i) {
items.add("refresh cnt " + (++start));
}
}

private void onLoad() {
mListView.stopRefresh();
mListView.stopLoadMore();
}

@Override
public void onRefresh() {
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
start = ++refreshCnt;
items.clear();
geneItems();
mAdapter.notifyDataSetChanged();
onLoad();
}
}, 3000);
}

@Override
public void onLoadMore() {
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
geneItems();
mAdapter.notifyDataSetChanged();
onLoad();
}
}, 3000);
}

public class XListViewActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
Loading

0 comments on commit 7a123f5

Please sign in to comment.