bundle

bundle傳集合

在這裏插入圖片描述

//String datas = new Gson().toJson(list);
轉成json

long time = list.get(i).getCreateTime();
//轉換
Date date = new Date(time);//用Date構造方法,將long轉Date
SimpleDateFormat format = new SimpleDateFormat(“yyyy-MM-dd”);
String stringDate = format.format(date);//用SimpleDateFormat將Date轉xxxx-xx-xx格式的字符串日期

//sp

private SharedPreferences.Editor editor;
    private SharedPreferences pref;


    //獲取sp
        pref= getSharedPreferences("xiaoqiang",Context.MODE_PRIVATE);
        editor = pref.edit();
        //選擇記住密碼
        boolean isRemenber = pref.getBoolean("remember_password", false);
        if (isRemenber) {
            //將賬號和密碼都設置到文本中
            String account = pref.getString("account", "");
            String password = pref.getString("password", "");
            LoginName.setText(account);
            loginPwd.setText(password);
            loginJzmm.setChecked(true);

        }

	
	 if (loginJzmm.isChecked()) {
                        editor.putBoolean("remember_password", true);
                        editor.putString("account", name);
                        editor.putString("password", pass);
                    } else {
                        editor.clear();
                    }
                    editor.apply();
	

/*            sp存*/
editor.putInt("userId",loginBean.getResult().getUserId());
            editor.putString("sessionId",loginBean.getResult().getSessionId());
            editor.putString("headPic",loginBean.getResult().getHeadPic());
            editor.putString("niceName",loginBean.getResult().getNickName());
            editor.putString("phone",loginBean.getResult().getPhone());
            editor.commit();


/*            sp取*/

SharedPreferences xiaoqiang = getSharedPreferences("xiaoqiang", Context.MODE_PRIVATE);
        userId = xiaoqiang.getInt("userId", 0);
        sessionId = xiaoqiang.getString("sessionId", "123");

//banner 輪播圖

	banner.setData(result, null);
	 banner.loadImage(new XBanner.XBannerAdapter() {
            @Override
            public void loadBanner(XBanner banner, Object model, View view, int position) {
                BannerBean.ResultBean model1 = (BannerBean.ResultBean) model;
                Glide.with(getActivity()).load(model1.getImageUrl()).into((ImageView) view);
            }
        });


//////xml
	  <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="@dimen/dp_180"
                android:clipChildren="false"
                android:orientation="horizontal">

                <com.stx.xhb.xbanner.XBanner
                    android:id="@+id/banner"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_centerHorizontal="true"
                    android:layout_gravity="center"
                    app:isClipChildrenMode="true"/>
            </RelativeLayout>


//依賴
		  //retrofit
    implementation 'com.squareup.retrofit2:retrofit:2.0.2'
    implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
    //rxjava
    implementation 'io.reactivex.rxjava2:rxjava:2.0.1'
    implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
    implementation 'com.squareup.retrofit2:adapter-rxjava2:2.2.0'
    //MetrialDesign:Design庫
    implementation 'com.android.support:design:28.+'
    //Brvah:RecyclerView快速開發框架
    implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.30'
    //fresco
    implementation 'com.facebook.fresco:fresco:1.13.0'
    //butterknife
    implementation 'com.jakewharton:butterknife:8.8.1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
    //xRecycleView
    implementation 'com.jcodecraeer:xrecyclerview:1.5.9'
    //XBanner
    //implementation 'com.github.bumptech.glide:glide:4.8.0'
    implementation 'com.github.xiaohaibin:XBanner:1.6.1'
    //gilde
    implementation 'com.github.bumptech.glide:glide:3.5.2'
    //SmartRefreshLayout
    implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0-alpha-19'
    //eventbus
    implementation 'org.greenrobot:eventbus:3.0.0'
    implementation 'com.youth.banner:banner:1.4.9'
    implementation('com.github.niorgai:StatusBarCompat:2.1.4', {
        exclude group: 'com.android.support'
    })
    //
    implementation "com.daimajia.swipelayout:library:1.2.0@aar"
    //三級聯動
    implementation 'liji.library.dev:citypickerview:1.1.0'
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章