Android development and android Development Environment Construction

Source: Internet
Author: User

Android development and android Development Environment Construction
Project source code

The project described in this article is open-source and the source code address

Why do PullToRefresh-PinnedSection-ListView

Some time ago, due to project requirements, we needed to add the pull-down refresh and multipart header hover effects to ListView in Android. Inspired by dkmeteor, Merge has two open-source projects on Github:

  • Android-PullToRefresh (handmark version, which is no longer updated)

  • StickyListHeaders (current version is 2.x)

    Because the StickyListHeaders code in the existing project is 1.x, StickyListHeadersListView inherits from ListView, so it is very smooth to do merge with PullToRefreshListView of handmark;

    But 2. the StickyListHeadersListView of Version x inherits from FrameLayout, and its integration with PullToRefresh is not smooth. If you want to split an independent lib, you will encounter many problems, therefore, another similar open-source project is used in the split-and-break head hover requirement:

  • Pinned-section-listview

How did I do it?

We have already introduced this process as "smooth:

1. in terms of Library, the Library Modification Based on PullToRefresh first makes it dependent on the Library of StickyListHeaders by copying src/com/handmark/pulltorefresh/library/PullToRefreshListView. java class to create a PullToRefreshPinnedSectionListView. java class;

2. Modify the createListView () method in the PullToRefreshPinnedSectionListView class and comment out the following code:

//        if (VERSION.SDK_INT >= VERSION_CODES.GINGERBREAD) {//            lv = new InternalListViewSDK9(context, attrs);//        } else {//            lv = new InternalListView(context, attrs);//        }

Add

lv = new PinnedSectionListView(context, attrs);

3. For Example, the system depends on the Library of PullToRefresh based on the example modification of pinned-section-listview;

4. Modify the main class resource file activity_main.xml and set the List component to a new class:

<com.handmark.pulltorefresh.library.PullToRefreshPinnedSectionListView xmlns:android="http://schemas.android.com/apk/res/android"android:id="@+id/list"android:layout_width="match_parent"android:layout_height="wrap_content"android:headerDividersEnabled="false"android:footerDividersEnabled="false"android:divider="@null"/>

5. Rewrite the getListView () method in SampleActivity. java class:

mpPullToRefreshPinnedSectionListView = (PullToRefreshPinnedSectionListView) findViewById(R.id.list);return mpPullToRefreshPinnedSectionListView.getRefreshableView();

You can use

 
ListView list = getListView();

Continue other operations of the original example. For details, refer to the project code.

Another Implementation Method

The implementation method in this example depends on the flexibility of the handmark drop-down refresh component. More importantly, the multipart head hover component must be inherited from the ListView implementation; therefore, the handmark version can also be used to pull down and refresh components and 1. implementation of the StickyListHeaders component of Version x;

Another implementation method is pull-to-refresh-sticky-list, which combines 2. version x's StickyListHeaders and johannilsson's android-pulltorefresh have different implementation forms, but the effect is similar. After reading the code, the implementation is "quite smooth". If you are interested, you can refer to this project;

Suggestions

We recommend that you use this class library if you are familiar with or have used the original component class library.


Build an Android Development Environment

2. Configure ADT (Figure 3.1 to figure 3.10)
Android project development can be performed only when the ADT plug-in and Android SDK are configured.
ADT Configuration:
Step 1: Open eclipse, double-click eclipse.exe, and click OK, as shown in Figure 3.1 to Figure 3.4;
Step 2: In eclipse, select "help-> Install New Software"-> click "add"-> select “archive..htm, select the adt-0.9.1.zip file, and click "OK"-> select "Developer Tools ", click "Next"-> "Finished"-> finish, select the terms of acceptance, and click "Finished" until the process is completed. After completion, eclipse is restarted. Figure 3.5 to figure 3.10;
3. Configure the Android SDK (Figure 3.1 to figure 3.14)
In eclipse, select "Window-> Preferences"-> "Android" in sequence. The Window shown in Figure 3.12 appears, close the warning window-> select the android sdk directory (decompressed by), 3.13, and click OK-> In Figure 3.14, click "Apply" and click "OK ", after the configuration is complete, return to the eclipse initial interface.
I have a document for you.
I have just configured the ADT version. If it is relatively high, you need to obtain an avd.

Build an Android Development Environment

2. Configure ADT (Figure 3.1 to figure 3.10)
Android project development can be performed only when the ADT plug-in and Android SDK are configured.
ADT Configuration:
Step 1: Open eclipse, double-click eclipse.exe, and click OK, as shown in Figure 3.1 to Figure 3.4;
Step 2: In eclipse, select "help-> Install New Software"-> click "add"-> select “archive..htm, select the adt-0.9.1.zip file, and click "OK"-> select "Developer Tools ", click "Next"-> "Finished"-> finish, select the terms of acceptance, and click "Finished" until the process is completed. After completion, eclipse is restarted. Figure 3.5 to figure 3.10;
3. Configure the Android SDK (Figure 3.1 to figure 3.14)
In eclipse, select "Window-> Preferences"-> "Android" in sequence. The Window shown in Figure 3.12 appears, close the warning window-> select the android sdk directory (decompressed by), 3.13, and click OK-> In Figure 3.14, click "Apply" and click "OK ", after the configuration is complete, return to the eclipse initial interface.
I have a document for you.
I have just configured the ADT version. If it is relatively high, you need to obtain an avd.

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.