Android安卓实战项目(2)—健身UI APP(源码在文末)
一.项目运行介绍
1.大致浏览
2.功能介绍
(1)功能一
第一个界面点击后可以弹出图像,如图:
(2)功能二
界面二的控件可以通过滑动下拉条来调解
二.具体实现
MainActivity.java
package com.example.fitnessui;
import androidx.appcompat.app.AppCompatActivity;
import androidx.viewpager.widget.ViewPager;
import android.os.Bundle;
import com.example.fitnessui.Fragment.ViewPagerAdapter;
import com.google.android.material.tabs.TabLayout;
public class MainActivity extends AppCompatActivity {
ViewPager viewPager;
TabLayout tabLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
viewPager = findViewById(R.id.MainActivty_MainPager);
tabLayout = findViewById(R.id.MainActivty_TableLayout);
ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager());
viewPager.setAdapter(adapter);
tabLayout.setupWithViewPager(viewPager);
}
}
PopupActivity.java
package com.example.fitnessui;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import com.example.fitnessui.Fragment.PopupFragment;
public class PopupActivity extends AppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.popupactivity);
FragmentManager fragmentManager = getSupportFragmentManager();
Fragment fragment = fragmentManager.findFragmentById(R.id.popupactivtyFrame);
if (fragment == null) {
fragment = PopupFragment.newInstance();
fragmentManager.beginTransaction().add(R.id.popupactivtyFrame, fragment).commit();
}
}
public static Intent newIntent(Context context, FitnessMove fitnessMove) {
Intent intent = new Intent(context, PopupActivity.class);
intent.putExtra("Info", fitnessMove);
return intent;
}
}
FitnessMove.java
package com.example.fitnessui;
import android.os.Parcel;
import android.os.Parcelable;
public class FitnessMove implements Parcelable {
private String fitnessName;
private String fitnessPictures;
private String fitnessDescription;
private int fitnessCalorie;
public FitnessMove(String fitnessName, String fitnessPictures, String fitnessDescription, int fitnessCalorie) {
this.fitnessName = fitnessName;
this.fitnessPictures = fitnessPictures;
this.fitnessDescription = fitnessDescription;
this.fitnessCalorie = fitnessCalorie;
}
public String getFitnessName() {
return fitnessName;
}
public String getFitnessPictures() {
return fitnessPictures;
}
public String getFitnessDescription() {
return fitnessDescription;
}
public int getFitnessCalorie() {
return fitnessCalorie;
}
protected FitnessMove(Parcel in) {
fitnessName = in.readString();
fitnessPictures = in.readString();
fitnessDescription = in.readString();
fitnessCalorie = in.readInt();
}
public static final Creator<FitnessMove> CREATOR = new Creator<FitnessMove>() {
@Override
public FitnessMove createFromParcel(Parcel in) {
return new FitnessMove(in);
}
@Override
public FitnessMove[] newArray(int size) {
return new FitnessMove[size];
}
};
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel parcel, int i) {
parcel.writeString(fitnessName);
parcel.writeString(fitnessPictures);
parcel.writeString(fitnessDescription);
parcel.writeInt(fitnessCalorie);
}
}
三.项目源码
链接:https://pan.baidu.com/s/1fE-Koh-VmnFOxNKF9CsQNA?pwd=jynl
提取码:jynl