List-Configuration
Target group: Android Beginner without foundation
Knowledge Points: The use of Recyclerview
Goal: Use Recyclerview to display list data in a page
Brief introduction
- Configuration of the Recyclerview Android studio
Body
1. Copy the Android-support-v7-recyclerview.jar to the project code corresponding to the Libs directory.
-
You can find this package in the Sdk\extras\android\support\v7\recyclerview\libs directory.
-
Take the MyApplication project as an example, the corresponding path to the Libs directory is myapplication\app\libs
2. Open the Build.gradle file and check to see if a reference to the package is added, complete with the following code
Apply plugin:' Com.android.application 'Android {Compilesdkversion +Buildtoolsversion"21.1.2"Defaultconfig {ApplicationID"Cnlive.com.myapplication"Minsdkversion theTargetsdkversion +Versioncode1Versionname"1.0"} buildtypes {release {minifyenabledfalseProguardfiles Getdefaultproguardfile (' Proguard-android.txt '),' Proguard-rules.pro '}}}dependencies {Compile Filetree (dir:' Libs ', include: [' *.jar ']) Compile' com.android.support:appcompat-v7:21.0.3 '}
- The Dependencies section is the dependency code referenced by this project
3. Click the top menu bar Build-make project, after the project is rebuilt, try to find the Recyclerview class in the code, one of the simplest examples is the following
@Override protectedvoidonCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); RecyclerView recyclerView; }
If the code completes without error, the project configuration succeeds
Android Basics (10)