more elegant demo
This commit is contained in:
parent
c93c76488a
commit
8bc91b6664
|
|
@ -7,7 +7,6 @@ import android.view.View;
|
|||
import android.widget.AdapterView;
|
||||
import android.widget.GridView;
|
||||
|
||||
import com.daimajia.swipe.SwipeAdapter;
|
||||
import com.daimajia.swipedemo.adapter.GridViewAdapter;
|
||||
|
||||
public class GridViewExample extends Activity{
|
||||
|
|
@ -18,7 +17,7 @@ public class GridViewExample extends Activity{
|
|||
setContentView(R.layout.gridview);
|
||||
final GridView gridView = (GridView)findViewById(R.id.gridview);
|
||||
final GridViewAdapter adapter = new GridViewAdapter(this);
|
||||
adapter.setMode(SwipeAdapter.Mode.Multiple);
|
||||
|
||||
gridView.setAdapter(adapter);
|
||||
gridView.setSelected(false);
|
||||
gridView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import android.widget.AbsListView;
|
|||
import android.widget.AdapterView;
|
||||
import android.widget.ListView;
|
||||
|
||||
import com.daimajia.swipe.SwipeAdapter;
|
||||
import com.daimajia.swipe.implments.SwipeItemMangerImpl;
|
||||
import com.daimajia.swipedemo.adapter.ListViewAdapter;
|
||||
|
||||
public class ListViewExample extends Activity {
|
||||
|
|
@ -25,9 +25,19 @@ public class ListViewExample extends Activity {
|
|||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.listview);
|
||||
mListView = (ListView)findViewById(R.id.listview);
|
||||
|
||||
/**
|
||||
* The following comment is the sample usage of ArraySwipeAdapter.
|
||||
*/
|
||||
// String[] adapterData = new String[]{"Activity", "Service", "Content Provider", "Intent", "BroadcastReceiver", "ADT", "Sqlite3", "HttpClient",
|
||||
// "DDMS", "Android Studio", "Fragment", "Loader", "Activity", "Service", "Content Provider", "Intent",
|
||||
// "BroadcastReceiver", "ADT", "Sqlite3", "HttpClient", "Activity", "Service", "Content Provider", "Intent",
|
||||
// "BroadcastReceiver", "ADT", "Sqlite3", "HttpClient"};
|
||||
// mListView.setAdapter(new ArraySwipeAdapterSample<String>(this, R.layout.listview_item, R.id.position, adapterData));
|
||||
|
||||
mAdapter = new ListViewAdapter(this);
|
||||
mListView.setAdapter(mAdapter);
|
||||
mAdapter.setMode(SwipeAdapter.Mode.Single);
|
||||
mAdapter.setMode(SwipeItemMangerImpl.Mode.Single);
|
||||
mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ public class NestedExample extends Activity{
|
|||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.nested);
|
||||
setContentView(R.layout.complicate_layout);
|
||||
findViewById(R.id.hhhhh).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,43 @@
|
|||
package com.daimajia.swipedemo.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.daimajia.swipe.adapters.ArraySwipeAdapter;
|
||||
import com.daimajia.swipedemo.R;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Sample usage of ArraySwipeAdapter.
|
||||
* @param <T>
|
||||
*/
|
||||
public class ArraySwipeAdapterSample<T> extends ArraySwipeAdapter {
|
||||
public ArraySwipeAdapterSample(Context context, int resource) {
|
||||
super(context, resource);
|
||||
}
|
||||
|
||||
public ArraySwipeAdapterSample(Context context, int resource, int textViewResourceId) {
|
||||
super(context, resource, textViewResourceId);
|
||||
}
|
||||
|
||||
public ArraySwipeAdapterSample(Context context, int resource, Object[] objects) {
|
||||
super(context, resource, objects);
|
||||
}
|
||||
|
||||
public ArraySwipeAdapterSample(Context context, int resource, int textViewResourceId, Object[] objects) {
|
||||
super(context, resource, textViewResourceId, objects);
|
||||
}
|
||||
|
||||
public ArraySwipeAdapterSample(Context context, int resource, List objects) {
|
||||
super(context, resource, objects);
|
||||
}
|
||||
|
||||
public ArraySwipeAdapterSample(Context context, int resource, int textViewResourceId, List objects) {
|
||||
super(context, resource, textViewResourceId, objects);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSwipeLayoutResourceId(int position) {
|
||||
return R.id.swipe;
|
||||
}
|
||||
}
|
||||
|
|
@ -6,10 +6,10 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.daimajia.swipe.SwipeAdapter;
|
||||
import com.daimajia.swipe.adapters.BaseSwipeAdapter;
|
||||
import com.daimajia.swipedemo.R;
|
||||
|
||||
public class GridViewAdapter extends SwipeAdapter {
|
||||
public class GridViewAdapter extends BaseSwipeAdapter {
|
||||
|
||||
private Context mContext;
|
||||
|
||||
|
|
|
|||
|
|
@ -8,12 +8,12 @@ import android.widget.TextView;
|
|||
|
||||
import com.daimajia.androidanimations.library.Techniques;
|
||||
import com.daimajia.androidanimations.library.YoYo;
|
||||
import com.daimajia.swipe.adapters.BaseSwipeAdapter;
|
||||
import com.daimajia.swipe.SimpleSwipeListener;
|
||||
import com.daimajia.swipe.SwipeAdapter;
|
||||
import com.daimajia.swipe.SwipeLayout;
|
||||
import com.daimajia.swipedemo.R;
|
||||
|
||||
public class ListViewAdapter extends SwipeAdapter {
|
||||
public class ListViewAdapter extends BaseSwipeAdapter {
|
||||
|
||||
private Context mContext;
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent" android:layout_height="match_parent">
|
||||
<include layout="@layout/sampe_nested_scrollview" android:layout_height="80dp" android:layout_width="match_parent"/>
|
||||
<include layout="@layout/sampe_nested_seekbar" android:layout_height="80dp" android:layout_width="match_parent" android:layout_marginTop="20dp"/>
|
||||
<include layout="@layout/sampe_nested_edittext" android:layout_height="80dp" android:layout_width="match_parent" android:layout_marginTop="20dp"/>
|
||||
</LinearLayout>
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<com.daimajia.swipe.SwipeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent" android:layout_height="match_parent">
|
||||
<LinearLayout
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="match_parent">
|
||||
<ImageView
|
||||
android:id="@+id/trash"
|
||||
android:src="@drawable/trash"
|
||||
android:layout_width="match_parent"
|
||||
android:background="#FF3B30"
|
||||
android:paddingLeft="25dp"
|
||||
android:paddingRight="25dp"
|
||||
android:layout_height="match_parent" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:padding="10dp"
|
||||
android:background="#ffffff"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<TextView
|
||||
android:text="EditText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
<EditText
|
||||
android:layout_gravity="right"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
</com.daimajia.swipe.SwipeLayout>
|
||||
|
|
@ -1,10 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<com.daimajia.swipe.SwipeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent" android:layout_height="80dp">
|
||||
|
||||
android:layout_width="match_parent" android:layout_height="match_parent">
|
||||
<LinearLayout
|
||||
android:tag="Bottom3"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="match_parent">
|
||||
<ScrollView
|
||||
|
|
@ -25,7 +23,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<TextView
|
||||
android:text="Test ScrollView"
|
||||
android:text="ScrollView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
<ScrollView
|
||||
|
|
@ -47,7 +45,7 @@
|
|||
android:text="HelloWorld"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
</LinearLayout>
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<com.daimajia.swipe.SwipeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent" android:layout_height="match_parent">
|
||||
<LinearLayout
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="match_parent">
|
||||
<ImageView
|
||||
android:id="@+id/trash"
|
||||
android:src="@drawable/trash"
|
||||
android:layout_width="match_parent"
|
||||
android:background="#FF3B30"
|
||||
android:paddingLeft="25dp"
|
||||
android:paddingRight="25dp"
|
||||
android:layout_height="match_parent" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:padding="10dp"
|
||||
android:background="#ffffff"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<TextView
|
||||
android:text="SeekBar"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
<SeekBar
|
||||
android:layout_gravity="center"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
</com.daimajia.swipe.SwipeLayout>
|
||||
|
|
@ -10,5 +10,5 @@
|
|||
android:orderInCategory="100"
|
||||
/>
|
||||
<item android:id="@+id/action_nexted"
|
||||
android:title="Nested"/>
|
||||
android:title="Complicate"/>
|
||||
</menu>
|
||||
|
|
|
|||
Loading…
Reference in New Issue