Permalink
Browse files

Added a button that calls notifyDataSetChanged() on the list adapter

  • Loading branch information...
1 parent 365489d commit 1ded7f010bc83b6f61ff062126e1a3249a55f967 daniel committed Jul 12, 2012
@@ -1,8 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:orientation="vertical" >
-<ListView
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@android:id/android:list"
- android:layout_height="match_parent"
- android:layout_width="match_parent"
- android:smoothScrollbar="true" />
+<!-- added by dwa012 -->
+ <Button
+ android:id="@+id/refresh_button"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="refresh" />
+
+ <ListView
+ android:id="@android:id/android:list"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:smoothScrollbar="true" />
+
+</LinearLayout>
@@ -57,7 +57,8 @@ private void verboseImageManagerSettings() {
settingsBuilder.withAsyncTasks(false);
//You can set a specific directory for caching files on the sdcard
- settingsBuilder.withCacheDir(new File("/something"));
+// settingsBuilder.withCacheDir(new File("/something"));
+
//Setting this to false means that file cache will use the url without the query part
//for the generation of the hashname
@@ -3,6 +3,8 @@
import android.database.Cursor;
import android.os.Bundle;
import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.Button;
import android.widget.ImageView;
import android.widget.SimpleCursorAdapter.ViewBinder;
@@ -43,6 +45,19 @@ public void onCreate(Bundle savedInstanceState) {
imageTagFactory = new ImageTagFactory(this, R.drawable.bg_img_loading);
imageTagFactory.setErrorImageId(R.drawable.bg_img_notfound);
setAdapter();
+
+ //added by dwa012
+ Button button = (Button) this.findViewById(R.id.refresh_button);
+ button.setOnClickListener(new OnClickListener(){
+
+ @Override
+ public void onClick(View v) {
+ refreshData();
+
+
+ }
+
+ });
}
/**
@@ -3,6 +3,8 @@
import android.database.Cursor;
import android.os.Bundle;
import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.Button;
import android.widget.ImageView;
import android.widget.SimpleCursorAdapter.ViewBinder;
@@ -47,6 +49,19 @@ public void onCreate(Bundle savedInstanceState) {
imageTagFactory.setErrorImageId(R.drawable.bg_img_notfound);
imageTagFactory.setSaveThumbnail(true);
setAdapter();
+
+ //added by dwa012
+ Button button = (Button) this.findViewById(R.id.refresh_button);
+ button.setOnClickListener(new OnClickListener(){
+
+ @Override
+ public void onClick(View v) {
+ refreshData();
+
+
+ }
+
+ });
}
/**
@@ -3,7 +3,10 @@
import android.database.Cursor;
import android.os.Bundle;
import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.Button;
import android.widget.ImageView;
+import android.widget.ListView;
import android.widget.SimpleCursorAdapter.ViewBinder;
import com.novoda.imageloader.core.ImageManager;
@@ -50,6 +53,19 @@ public void onCreate(Bundle savedInstanceState) {
imageTagFactory.setErrorImageId(R.drawable.bg_img_notfound);
imageTagFactory.setSaveThumbnail(true);
setAdapter();
+
+ //added by dwa012
+ Button button = (Button) this.findViewById(R.id.refresh_button);
+ button.setOnClickListener(new OnClickListener(){
+
+ @Override
+ public void onClick(View v) {
+ refreshData();
+
+
+ }
+
+ });
}
/**
@@ -13,6 +13,9 @@
private static final String[] FROM = new String[] { "url" };
private static final int[] TO = new int[] { R.id.list_item_image };
+
+ //added by dwa012
+ private SimpleCursorAdapter adapter;
protected int getImageItem() {
return R.layout.image_item;
@@ -30,14 +33,23 @@ private Cursor getCursor() {
protected abstract String getTableName();
protected void setAdapter() {
- SimpleCursorAdapter adapter = initAdapter();
+
+ //changed by dwa012
+// SimpleCursorAdapter adapter = initAdapter();
+ adapter = initAdapter();
ListView lv = getListView();
ViewBinder binder = getViewBinder();
if (binder != null) {
adapter.setViewBinder(binder);
}
lv.setAdapter(adapter);
}
+
+ //added by dwa012
+ protected void refreshData(){
+ adapter.notifyDataSetChanged();
+ }
+
protected abstract ViewBinder getViewBinder();

0 comments on commit 1ded7f0

Please sign in to comment.