my music:
1, project creation:
Project framework:
Front and back page development:
1, index page:
Core code:
private void init() {
mtimer=new Timer();
mtimer.schedule(new TimerTask() {
@Override
public void run() {
Log.e("索引页面", "----");//打印日志
toMain();
}
},3000);
}
private void toMain() {
Intent intent=new Intent(this,MainActivity.class);//调换页面
startActivity(intent);//将他设置成活动页面
finish();//结束
}
2 Home:
3, the login page:
初始化头页面:
private void initView() {
initNavBar(false,"登录",false);
}
4, the proxy class: [Front: page head - public quote]: on a separate page, so that other pages referenced
核心代码:
private ImageView iv_back,iv_me;
private TextView tv_title;
protected void initNavBar(boolean isShowBack,String title,boolean isShowUser){
iv_back=Rid(R.id.iv_back);//退回图标
iv_me=Rid(R.id.iv_me);//用户添加图标
tv_title=Rid(R.id.tv_title);//页面标题
//逻辑显示
iv_back.setVisibility(isShowBack?View.VISIBLE:View.GONE);
iv_me.setVisibility(isShowBack?View.VISIBLE:View.GONE);
tv_title.setText(title);
//后退操作
iv_back.setOnClickListener(new View.OnClickListener(){//点击事件
@Override
public void onClick(View v) {
onBackPressed();
}
});
}
protected <T extends View> T Rid(@IdRes int id){
return findViewById(id);//获取页面中对应的id
}
Custom Control [Front: Custom Controls Page - public reference]:
public class InputView extends FrameLayout {
private int inputIcon;
private String inputHint;
private boolean isPassword;
public InputView(@NonNull Context context) {
super(context);
init(context,null);
}
public InputView(@NonNull Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
init(context,attrs);
}
public InputView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(context,attrs);
}
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)//API21以上使用
public InputView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
init(context,attrs);
}
private void init(Context context,AttributeSet attributeSet){
if(attributeSet==null){return;}
//获取自定义属性
TypedArray typedArray = context.obtainStyledAttributes(attributeSet, R.styleable.inputView);
inputIcon = typedArray.getIndex(R.styleable.inputView_input_icon);
inputHint = typedArray.getString(R.styleable.inputView_input_hint);
isPassword = typedArray.getBoolean(R.styleable.inputView_is_password,false);
typedArray.recycle();//手动关闭
}
}
Configuration instructions
Those unified management configuration file:
color.xml: Custom colors references
string.xml: Custom page text
mipmap: entire application image
attrs.xml custom
dimen.xml: Higher width provided between the pages of the tab
Configuration File
AndroidManifest.xml: application manifest file
<xml Version = "1.0" encoding = "UTF-8"??>
<The manifest xmlns: Android = "http://schemas.android.com/apk/res/android" xmlns: Android Android is defined namespace.
package = "com.example.livemingmusic"> full Java language style package name for Android apps.
<application
android:name=".MyApplication" Application 为应用程序实现的子类的完全限定名称
android:allowBackup="true" 是否允许应用程序参与备份和还原基础结构。
android:icon="@mipmap/themeimg" 整个应用程序的图标,以及每个应用程序组件的默认图标。
android:label="@string/app_name" 整个应用程序的用户可读标签,以及每个应用程序组件的默认标签。
android:roundIcon="@mipmap/themeimg"
android:supportsRtl="true" 声明您的应用程序是否愿意支持从右到左(RTL)布局。
android:theme="@style/AppTheme"> 对样式资源的引用,该样式资源为应用程序中的所有活动定义了默认主题。
<activity android:name=".activitys.LoginActivity"/>
<activity android:name=".activitys.MainActivity" />
<activity android:name=".activitys.WelcomeActivity">
<intent-filter><意图过滤器>
<action android:name="android.intent.action.MAIN" />动作的名称。在Intent类中将一些标准动作定义 为 常量。
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>