個人的な音楽アプリ

マイミュージック:

1、プロジェクトの作成:

空のプロジェクトを作成します。
直接仕上げ記入

プロジェクトのフレームワーク:

アプリ

フロントとバックのページの開発:

1、インデックスページ:

インデックスページ
コアコード:

		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ホーム:

3、ログインページ:

			初始化头页面:
			 private void initView() {
   					 initNavBar(false,"登录",false);
			}

4、プロキシクラス:[フロント:ページの頭 - 公共引用]:別のページに、他のページが参照さそうということ

核心代码:
					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
			    }

カスタムコントロール[フロント:カスタムページを制御します - 公共の参照]:

パブリッククラスInputViewはでframeLayout {拡張
;プライベートint型inputIconを
プライベート文字列inputHint。
プライベートブール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();//手动关闭
}

}

設定手順

これらの統合管理コンフィギュレーションファイル:

color.xml:カスタム色の参照の
string.xmlを:カスタムページのテキスト
ミップマップ:アプリケーション全体のイメージ
attrs.xmlカスタム
dimen.xml:タブのページの間に設けられた高さ幅

設定ファイル

AndroidManifest.xml:アプリケーションマニフェストファイル
<xmlのバージョン= "1.0"エンコード= "UTF-8"?>
<マニフェストのxmlns:アンドロイド= "http://schemas.android.com/apk/res/android"のxmlns:アンドロイドAndroidのは、名前空間を定義しています。
パッケージ= Androidアプリのための「com.example.livemingmusic」>完全なJava言語のスタイルのパッケージ名。

<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>
公開された26元の記事 ウォンの賞賛0 ビュー719

おすすめ

転載: blog.csdn.net/YHM_MM/article/details/102763186