This commit is contained in:
daimajia 2015-04-08 07:59:59 +08:00
commit feafd6a835
14 changed files with 672 additions and 666 deletions

View File

@ -68,7 +68,7 @@ public class ListViewExample extends Activity {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
Toast.makeText(mContext, "OnItemLongClickListener", Toast.LENGTH_SHORT).show();
return false;
return true;
}
});
mListView.setOnScrollListener(new AbsListView.OnScrollListener() {

View File

@ -4,6 +4,7 @@ import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
@ -28,9 +29,9 @@ public class MyActivity extends Activity {
sample1 = (SwipeLayout) findViewById(R.id.sample1);
sample1.setShowMode(SwipeLayout.ShowMode.PullOut);
sample1.setDragEdges(SwipeLayout.DragEdge.Left, SwipeLayout.DragEdge.Right, SwipeLayout.DragEdge.Top);
// sample1.setDragEdges(SwipeLayout.DragEdge.Left, SwipeLayout.DragEdge.Right, SwipeLayout.DragEdge.Top);
// When using multiple drag edges it's a good idea to pass the ids of the views that you're using for the left, right, top bottom views (-1 if you're not using a particular view)
sample1.setBottomViewIds(R.id.bottom_wrapper, R.id.bottom_wrapper_2, R.id.starbott, SwipeLayout.EMPTY_LAYOUT);
sample1.setBottomViewIds(R.id.bottom_wrapper, R.id.bottom_wrapper_2, R.id.starbott, R.id.starbott);
sample1.addRevealListener(R.id.delete, new SwipeLayout.OnRevealListener() {
@Override
public void onReveal(View child, SwipeLayout.DragEdge edge, float fraction, int distance) {
@ -38,6 +39,21 @@ public class MyActivity extends Activity {
}
});
sample1.getSurfaceView().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MyActivity.this, "Click on surface", Toast.LENGTH_SHORT).show();
Log.d(MyActivity.class.getName(), "click on surface");
}
});
sample1.getSurfaceView().setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
Toast.makeText(MyActivity.this, "longClick on surface", Toast.LENGTH_SHORT).show();
Log.d(MyActivity.class.getName(), "longClick on surface");
return true;
}
});
sample1.findViewById(R.id.star2).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -103,6 +119,12 @@ public class MyActivity extends Activity {
Toast.makeText(MyActivity.this, "Yo", Toast.LENGTH_SHORT).show();
}
});
sample2.getSurfaceView().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MyActivity.this, "Click on surface", Toast.LENGTH_SHORT).show();
}
});
//sample3
@ -120,12 +142,18 @@ public class MyActivity extends Activity {
child.setBackgroundColor(c);
}
});
sample3.findViewById(R.id.star).setOnClickListener(new View.OnClickListener() {
sample3.findViewById(R.id.bottom_wrapper_child1).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MyActivity.this, "Yo!", Toast.LENGTH_SHORT).show();
}
});
sample3.getSurfaceView().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MyActivity.this, "Click on surface", Toast.LENGTH_SHORT).show();
}
});
}

View File

@ -43,6 +43,12 @@ public class ListViewAdapter extends BaseSwipeAdapter {
Toast.makeText(mContext, "DoubleClick", Toast.LENGTH_SHORT).show();
}
});
v.findViewById(R.id.delete).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(mContext, "click delete", Toast.LENGTH_SHORT).show();
}
});
return v;
}

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/dark_gray_press" android:state_pressed="true"/>
<item android:drawable="@color/dark_gray_press" android:state_focused="true"/>
<item android:drawable="@color/dark_gray"/>
</selector>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/red_press" android:state_pressed="true"/>
<item android:drawable="@color/red_press" android:state_focused="true"/>
<item android:drawable="@color/red"/>
</selector>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:color/darker_gray" android:state_pressed="true"/>
<item android:drawable="@android:color/darker_gray" android:state_focused="true"/>
<item android:drawable="@android:color/white"/>
</selector>

View File

@ -36,7 +36,7 @@
android:layout_width="0dp"
android:layout_height="40dp"
android:layout_weight="4"
android:background="#ffffff"
android:background="@drawable/white"
android:text="Yes,Delete"
android:textColor="#FF5534" />
</LinearLayout>

View File

@ -1,12 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<com.daimajia.swipe.SwipeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/godfather"
android:layout_width="match_parent" android:layout_height="match_parent"
app:drag_edge="bottom">
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_gravity="left|right|top"
android:src="@drawable/bird"
android:layout_width="100dp"
android:layout_height="100dp" />
<LinearLayout
android:id="@+id/bird_bottom"
android:layout_gravity="bottom"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="match_parent">

View File

@ -1,9 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<com.daimajia.swipe.SwipeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@drawable/item_selector"
<com.daimajia.swipe.SwipeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="80dp">
android:layout_height="80dp"
app:clickToClose="true">
<LinearLayout
android:tag="Bottom1"
@ -19,7 +21,8 @@
android:text="Archive"
android:layout_weight="0.5"
android:gravity="center"
android:background="#FF1300"
android:clickable="true"
android:background="@drawable/red"
android:layout_width="wrap_content"
android:layout_height="match_parent" />
@ -61,7 +64,7 @@
android:id="@+id/trash2"
android:src="@drawable/trash"
android:layout_width="70dp"
android:background="#FF3B30"
android:background="@drawable/red"
android:paddingLeft="25dp"
android:paddingRight="25dp"
android:layout_height="match_parent" />
@ -74,7 +77,8 @@
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/bottom_wrapper_child1"
android:background="#4C535B"
android:background="@drawable/dark_gray"
android:clickable="true"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
@ -87,17 +91,12 @@
</RelativeLayout>
</LinearLayout>
<LinearLayout
<TextView
android:padding="10dp"
android:background="#ffffff"
android:background="@drawable/white"
android:tag="Hover"
android:text="要有最樸素的生活和最遙遠的夢想,即使明天天寒地凍,山高水遠,路遠馬亡。"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:tag="Hover"
android:text="要有最樸素的生活和最遙遠的夢想,即使明天天寒地凍,山高水遠,路遠馬亡。"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
android:layout_height="match_parent" />
</com.daimajia.swipe.SwipeLayout>

View File

@ -26,7 +26,7 @@
android:id="@+id/trash"
android:src="@drawable/trash"
android:layout_width="70dp"
android:background="#FF3B30"
android:background="@drawable/red"
android:paddingLeft="25dp"
android:paddingRight="25dp"
android:layout_height="match_parent" />
@ -35,7 +35,7 @@
<LinearLayout
android:padding="10dp"
android:orientation="vertical"
android:background="#ffffff"
android:background="@drawable/white"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView

View File

@ -22,15 +22,11 @@
</RelativeLayout>
</LinearLayout>
<LinearLayout
<TextView
android:padding="10dp"
android:background="#ffffff"
android:tag="Hover"
android:text="None is of freedom or of life deserving unless he daily conquers it anew. "
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:tag="Hover"
android:text="None is of freedom or of life deserving unless he daily conquers it anew. "
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
android:layout_height="match_parent" />
</com.daimajia.swipe.SwipeLayout>

View File

@ -2,4 +2,8 @@
<resources>
<color name="backgroundColor">#E8E8E0</color>
<color name="backgroundColorPress">#DBDBD3</color>
<color name="red">#FF3B00</color>
<color name="red_press">#990000</color>
<color name="dark_gray">#4C535B</color>
<color name="dark_gray_press">#ff7e8a97</color>
</resources>

File diff suppressed because it is too large Load Diff

View File

@ -15,5 +15,6 @@
<enum name="lay_down" value="0" />
<enum name="pull_out" value="1" />
</attr>
<attr name="clickToClose" format="boolean" />
</declare-styleable>
</resources>