Google electronic market 9-Details page, Google electronic market 9 --

Source: Internet
Author: User

Google electronic market 9-Details page, Google electronic market 9 --

1. Details page (HomeDetailActivity)

@ Overrideprotected void onCreate (Bundle savedInstanceState) {super. onCreate (savedInstanceState); // initialize the loading page mLoadingPage = new LoadingPage (UIUtils. getContext () {@ Override public View onCreateSuccessView () {return HomeDetailActivity. this. onCreateSuccessView () ;}@ Override public ResultState onLoad () {return HomeDetailActivity. this. onLoad () ;}}; setContentView (mLoadingPage); mPackageName = getIn Tent (). getStringExtra ("package"); // starts loading the data mLoadingPage. loadData ();}/*** load network data * @ return */public ResultState onLoad () {HomeDetailProtocol protocol = new HomeDetailProtocol (mPackageName); mData = protocol. getData (0); if (mData! = Null) {return ResultState. STATE_SUCCESS;} else {return ResultState. STATE_ERROR ;}}

2. AppInfo)

AppInfo New Field

Public class AppInfo {public String des; public String downloadUrl; public String iconUrl; public String id; public String name; public String packageName; public long size; public double stars; // public String author; public String date; public String downloadNum; public String version; public ArrayList <SafeInfo> safe; public ArrayList <String> screen; public static class SafeInfo {public String safeDes; public int safeDesColor; public String safeDesUrl; public String safeUrl ;}}

3. Details page layout Development

Idea: Use ScrollView to wrap and ensure smooth up and down. Each module uses FrameLayout as a container and dynamically adds the layout of relevant modules.

layout_home_detail.xml<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent" ><LinearLayout    android:layout_width="match_parent"    android:layout_height="wrap_content"    android:orientation="vertical"    android:padding="3dp" >    <FrameLayout        android:id="@+id/fl_detail_appinfo"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:background="@drawable/list_item_bg_selector" >    </FrameLayout>    <FrameLayout        android:id="@+id/fl_detail_safeinfo"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:background="@drawable/list_item_bg_selector" >    </FrameLayout>    <HorizontalScrollView        android:id="@+id/hsv_detail_pics"        android:layout_width="match_parent"        android:layout_height="wrap_content" >    </HorizontalScrollView>    <FrameLayout        android:id="@+id/fl_detail_des"        android:layout_width="match_parent"        android:layout_height="wrap_content" >    </FrameLayout></LinearLayout></ScrollView>

4. Expand and collapse the animation effect

/*** Expand or collapse the Security Description */protected void toggle () {// nineoldandroids need to be introduced. jar, which is compatible with ValueAnimator animator of versions earlier than api11; if (isExpanded) {// collapse the description isExpanded = false; // initialize the animation that changes according to the specified value, the layout height changes from mDesRootHeight to 0. After this method is called and the animation is enabled, // The latest height value is continuously called back in the onAnimationUpdate method, update the layout height in onAnimationUpdate: animator = ValueAnimator. ofInt (mDesRootHeight, 0);} else {// expand description isExpanded = true; // Initialize an animation that changes according to the specified value, the layout height changes from 0 to mDesRootHeight animator = ValueAnimator. ofInt (0, mDesRootHeight);} // sets the animation update listener to animator. addUpdateListener (new AnimatorUpdateListener () {// After the animation starts, this method will be called back every time the animation has the latest status @ Override public void onAnimationUpdate (ValueAnimator valueAnimator) {// obtain the latest height Information Integer height = (Integer) valueAnimator. getAnimatedValue (); mParams. height = height; // update the height of the security description llDesRoot. setLayoutParams (mParams) ;}}); // sets the animation listening to animator. addListener (new AnimatorListener () {@ Override public void onAnimationStart (Animator arg0) {// animation start} @ Override public void onAnimationRepeat (Animator arg0) {// animation repetition} @ Override public void onAnimationEnd (Animator arg0) {// animation end // update the Security ID. The Arrow is directed to if (isExpanded) {ivArrow. setImageResource (R. drawable. arrow_up);} else {ivArrow. setImageResource (R. drawable. arrow_down) ;}}@ Override public void onAnimationCancel (Animator arg0) {// animation cancel}}); // set the animation time to animator. setDuration (200); // enable animation or. start ();}

  

  

  

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.