forked from gzu-liyujiang/AndroidPicker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add custom header and footer, custom animation
- Loading branch information
1 parent
521c963
commit f07c39f
Showing
6 changed files
with
169 additions
and
8 deletions.
There are no files selected for viewing
92 changes: 92 additions & 0 deletions
92
app/src/main/java/cn/qqtheme/androidpicker/CustomHeaderAndFooterPicker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
package cn.qqtheme.androidpicker; | ||
|
||
import android.app.Activity; | ||
import android.support.annotation.Nullable; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.animation.AccelerateInterpolator; | ||
import android.widget.Button; | ||
import android.widget.TextView; | ||
|
||
import com.github.florent37.viewanimator.AnimationListener; | ||
import com.github.florent37.viewanimator.ViewAnimator; | ||
|
||
import cn.qqtheme.framework.picker.OptionPicker; | ||
|
||
/** | ||
* 自定义顶部及底部 | ||
* <p/> | ||
* Author:李玉江[QQ:1032694760] | ||
* Email:[email protected] | ||
* DateTime:2016/1/29 14:47 | ||
* Builder:Android Studio | ||
*/ | ||
public class CustomHeaderAndFooterPicker extends OptionPicker { | ||
|
||
public CustomHeaderAndFooterPicker(Activity activity) { | ||
super(activity, new String[]{ | ||
"C/C++", "Java", "PHP", "Swift", "Node.js", "C#", "HTML5" | ||
}); | ||
setTitleText("请选择你最擅长的语言"); | ||
setSelectedItem("PHP"); | ||
} | ||
|
||
@Override | ||
public void show() { | ||
super.show(); | ||
ViewAnimator.animate(getRootView()) | ||
.duration(2000) | ||
.interpolator(new AccelerateInterpolator()) | ||
.slideBottom() | ||
.start(); | ||
} | ||
|
||
@Override | ||
public void dismiss() { | ||
ViewAnimator.animate(getRootView()) | ||
.duration(1000) | ||
.rollOut() | ||
.onStop(new AnimationListener.Stop() { | ||
@Override | ||
public void onStop() { | ||
CustomHeaderAndFooterPicker.super.dismiss(); | ||
} | ||
}) | ||
.start(); | ||
} | ||
|
||
@Nullable | ||
@Override | ||
protected View makeHeaderView() { | ||
View view = LayoutInflater.from(activity).inflate(R.layout.picker_header, null); | ||
TextView titleView = (TextView) view.findViewById(R.id.picker_title); | ||
titleView.setText(titleText); | ||
return view; | ||
} | ||
|
||
@Nullable | ||
@Override | ||
protected View makeFooterView() { | ||
View view = LayoutInflater.from(activity).inflate(R.layout.picker_footer, null); | ||
Button submitView = (Button) view.findViewById(R.id.picker_submit); | ||
submitView.setText(submitText); | ||
submitView.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
dismiss(); | ||
onSubmit(); | ||
} | ||
}); | ||
Button cancelView = (Button) view.findViewById(R.id.picker_cancel); | ||
cancelView.setText(cancelText); | ||
cancelView.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
dismiss(); | ||
onCancel(); | ||
} | ||
}); | ||
return view; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="vertical"> | ||
|
||
<View | ||
android:layout_width="match_parent" | ||
android:layout_height="1dp" | ||
android:layout_marginTop="10dp" | ||
android:background="#FFEEEEEE" /> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_margin="10dp" | ||
android:gravity="center_horizontal" | ||
android:orientation="horizontal"> | ||
|
||
<Button | ||
android:id="@+id/picker_submit" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="submit" /> | ||
|
||
<Button | ||
android:id="@+id/picker_cancel" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginLeft="10dp" | ||
android:text="cancel" | ||
android:textColor="#FFFF0000" /> | ||
|
||
</LinearLayout> | ||
|
||
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical"> | ||
|
||
<TextView | ||
android:id="@+id/picker_title" | ||
android:layout_width="match_parent" | ||
android:layout_height="40dp" | ||
android:gravity="center" | ||
android:text="New Text" /> | ||
|
||
</LinearLayout> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.