我的主页面

1.整体布局

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1.5"
        android:orientation="horizontal"
        android:background="@drawable/timg"

        >

        <Button
            android:layout_width="25dp"
            android:layout_height="25dp"
            android:background="@drawable/she_black_24dp"
            android:id="@+id/btn_she"
            />


        <com.facebook.drawee.view.SimpleDraweeView
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:background="@drawable/user"
            android:layout_marginLeft="10dp"
            android:layout_marginTop="20dp"
            android:id="@+id/simp_my"
            />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="登录/注册"
            android:textSize="25sp"
            android:layout_marginTop="25dp"
            android:layout_marginLeft="280dp"
            android:id="@+id/text_my"
            />


    </LinearLayout>

    <Button
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:background="@drawable/my"
        />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="0.4"
        android:text="为您推荐"
        android:textColor="#f00"
        android:layout_gravity="center"
        android:gravity="center"
        android:textSize="20sp"
        android:background="#DDD6FF"
        />

    <android.support.v7.widget.RecyclerView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="4"
        android:id="@+id/rece_my"
        />

</LinearLayout>

2.主页面

public class MyFragment extends BaseFragment<MyPresenter> implements MyContract.View {

    @BindView(R.id.simp_my)
    SimpleDraweeView simpMy;
    @BindView(R.id.text_my)
    TextView textMy;
    @BindView(R.id.rece_my)
    RecyclerView receMy;
    Unbinder unbinder;
    @BindView(R.id.btn_she)
    Button btnShe;

    public static MyFragment newInstance() {
        MyFragment fragment = new MyFragment();
        return fragment;
    }

    @Override
    public void setupFragmentComponent(@NonNull AppComponent appComponent) {
        DaggerMyComponent //如找不到该类,请编译一下项目
                .builder()
                .appComponent(appComponent)
                .myModule(new MyModule(this))
                .build()
                .inject(this);
    }

    @Override
    public View initView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_my, container, false);
    }

    @Override
    public void initData(@Nullable Bundle savedInstanceState) {

        RoundingParams roundingParams = RoundingParams.fromCornersRadius(5f);
        roundingParams.setRoundAsCircle(true);
        simpMy.getHierarchy().setRoundingParams(roundingParams);
    }

    /**
     * 通过此方法可以使 Fragment 能够与外界做一些交互和通信, 比如说外部的 Activity 想让自己持有的某个 Fragment 对象执行一些方法,
     * 建议在有多个需要与外界交互的方法时, 统一传 {@link Message}, 通过 what 字段来区分不同的方法, 在 {@link #setData(Object)}
     * 方法中就可以 {@code switch} 做不同的操作, 这样就可以用统一的入口方法做多个不同的操作, 可以起到分发的作用
     * <p>
     * 调用此方法时请注意调用时 Fragment 的生命周期, 如果调用 {@link #setData(Object)} 方法时 {@link Fragment#onCreate(Bundle)} 还没执行
     * 但在 {@link #setData(Object)} 里却调用了 Presenter 的方法, 是会报空的, 因为 Dagger 注入是在 {@link Fragment#onCreate(Bundle)} 方法中执行的
     * 然后才创建的 Presenter, 如果要做一些初始化操作,可以不必让外部调用 {@link #setData(Object)}, 在 {@link #initData(Bundle)} 中初始化就可以了
     * <p>
     * Example usage:
     * <pre>
     * public void setData(@Nullable Object data) {
     *     if (data != null && data instanceof Message) {
     *         switch (((Message) data).what) {
     *             case 0:
     *                 loadData(((Message) data).arg1);
     *                 break;
     *             case 1:
     *                 refreshUI();
     *                 break;
     *             default:
     *                 //do something
     *                 break;
     *         }
     *     }
     * }
     *
     * // call setData(Object):
     * Message data = new Message();
     * data.what = 0;
     * data.arg1 = 1;
     * fragment.setData(data);
     * </pre>
     *
     * @param data 当不需要参数时 {@code data} 可以为 {@code null}
     */
    @Override
    public void setData(@Nullable Object data) {

    }

    @Override
    public void showLoading() {

    }

    @Override
    public void hideLoading() {

    }

    @Override
    public void showMessage(@NonNull String message) {
        checkNotNull(message);
        ArmsUtils.snackbarText(message);
    }

    @Override
    public void launchActivity(@NonNull Intent intent) {
        checkNotNull(intent);
        ArmsUtils.startActivity(intent);
    }

    @Override
    public void killMyself() {

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // TODO: inflate a fragment view
        View rootView = super.onCreateView(inflater, container, savedInstanceState);
        unbinder = ButterKnife.bind(this, rootView);
        mPresenter.getzhanshi();
        return rootView;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }


    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        if (requestCode == 999 && resultCode == 1) {
            String mobile = data.getExtras().getString("mobile");
            textMy.setText(mobile);
        } else {
            if (requestCode == 999 && resultCode == 888) {
                String name = data.getExtras().getString("name");
                String iconurl = data.getExtras().getString("iconurl");
                textMy.setText(name);

                Uri parse = Uri.parse(iconurl);
                simpMy.setImageURI(parse);
            }
        }
    }

    @OnClick({R.id.btn_she, R.id.text_my})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.btn_she:
                Intent intent1 = new Intent(getActivity(), SheZhiActivity.class);
                startActivity(intent1);
                break;
            case R.id.text_my:
                Intent intent = new Intent(getActivity(), LoginActivity.class);
                startActivityForResult(intent,999);
                break;
        }
    }

    @Override
    public void showData(NewsZhan newsZhan) {
        List<NewsZhan.DataBean.TuijianBean.ListBeanX> listzhan = newsZhan.getData().getTuijian().getList();
        GridLayoutManager manager = new GridLayoutManager(getActivity(), 2, GridLayoutManager.VERTICAL, false);
        receMy.setLayoutManager(manager);
        MyZhanshiAdapter myZhanshiAdapter = new MyZhanshiAdapter(getActivity(), listzhan);
        receMy.setAdapter(myZhanshiAdapter);
        myZhanshiAdapter.setOnItemClickLisentener(new MyZhanshiAdapter.onItemClickLisentener() {
            @Override
            public void onItemClick(int layoutPosition) {
                int pid = listzhan.get(layoutPosition).getPid();
                Intent intent = new Intent(getActivity(), ZhanXiangActivity.class);
                intent.putExtra("pid", pid + "");
                startActivity(intent);
            }
        });
    }
}
 

3.登录页面java

public class LoginActivity extends BaseActivity<LoginPresenter> implements LoginContract.View {

    @BindView(R.id.edit_dengphone)
    EditText editDengphone;
    @BindView(R.id.edit_dengpassword)
    EditText editDengpassword;
    @BindView(R.id.btn_login)
    Button btnLogin;
    @BindView(R.id.btn_zhuce)
    Button btnZhuce;
    @BindView(R.id.btn_q)
    Button btnQ;
    private String name;
    private String iconurl;
    UMAuthListener authListener = new UMAuthListener() {
        /**
         * @desc 授权开始的回调
         * @param platform 平台名称
         */
        @Override
        public void onStart(SHARE_MEDIA platform) {

        }

        /**
         * @desc 授权成功的回调
         * @param platform 平台名称
         * @param action 行为序号,开发者用不上
         * @param data 用户资料返回
         */
        @Override
        public void onComplete(SHARE_MEDIA platform, int action, Map<String, String> data) {

            Toast.makeText(LoginActivity.this, "成功了", Toast.LENGTH_SHORT).show();

            name = data.get("name");
            iconurl = data.get("iconurl");
            Intent intent2 = new Intent();
            Bundle bundle = new Bundle();
            bundle.putString("name",name);
            bundle.putString("iconurl",iconurl);
            intent2.putExtras(bundle);
            setResult(888,intent2);
            finish();
        }

        /**
         * @desc 授权失败的回调
         * @param platform 平台名称
         * @param action 行为序号,开发者用不上
         * @param t 错误原因
         */
        @Override
        public void onError(SHARE_MEDIA platform, int action, Throwable t) {

            Toast.makeText(LoginActivity.this, "失败:" + t.getMessage(),                                     Toast.LENGTH_SHORT).show();
        }

        /**
         * @desc 授权取消的回调
         * @param platform 平台名称
         * @param action 行为序号,开发者用不上
         */
        @Override
        public void onCancel(SHARE_MEDIA platform, int action) {
            Toast.makeText(LoginActivity.this, "取消了", Toast.LENGTH_SHORT).show();
        }
    };

    @Override
    public void setupActivityComponent(@NonNull AppComponent appComponent) {
        DaggerLoginComponent //如找不到该类,请编译一下项目
                .builder()
                .appComponent(appComponent)
                .loginModule(new LoginModule(this))
                .build()
                .inject(this);
    }

    @Override
    public int initView(@Nullable Bundle savedInstanceState) {
        return R.layout.activity_login; //如果你不需要框架帮你设置 setContentView(id) 需要自行设置,请返回 0
    }

    @Override
    public void initData(@Nullable Bundle savedInstanceState) {

        if(Build.VERSION.SDK_INT>=23){
            String[] mPermissionList = new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE,Manifest.permission.ACCESS_FINE_LOCATION,Manifest.permission.CALL_PHONE,Manifest.permission.READ_LOGS,Manifest.permission.READ_PHONE_STATE, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.SET_DEBUG_APP,Manifest.permission.SYSTEM_ALERT_WINDOW,Manifest.permission.GET_ACCOUNTS,Manifest.permission.WRITE_APN_SETTINGS};
            ActivityCompat.requestPermissions(this,mPermissionList,123);
        }
    }

    @Override
    public void showLoading() {

    }

    @Override
    public void hideLoading() {

    }

    @Override
    public void showMessage(@NonNull String message) {
        checkNotNull(message);
        ArmsUtils.snackbarText(message);
    }

    @Override
    public void launchActivity(@NonNull Intent intent) {
        checkNotNull(intent);
        ArmsUtils.startActivity(intent);
    }

    @Override
    public void killMyself() {
        finish();
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }

    @Override
    public void onRequestPermissionsResult(int requestCode,
                                           String permissions[], int[] grantResults) {

    }

    @OnClick({R.id.btn_login, R.id.btn_zhuce, R.id.btn_q})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.btn_login:
                String s = editDengphone.getText().toString();
                String s1 = editDengpassword.getText().toString();
                mPresenter.getlogin(s,s1);
                break;
            case R.id.btn_zhuce:
                Intent intent = new Intent(LoginActivity.this, ZhuceActivity.class);
                startActivityForResult(intent,999);
                break;
            case R.id.btn_q:
                UMShareAPI.get(this).getPlatformInfo(LoginActivity.this,SHARE_MEDIA.QQ,authListener);
                break;
        }
    }

    @Override
    public void showData(NewsLogin newsLogin) {

        String code = newsLogin.getCode();
        String msg = newsLogin.getMsg();
        if(code.equals("0"))
        {
            String mobile = newsLogin.getData().getMobile();
            Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
            Intent intent = new Intent();
            Bundle bundle = new Bundle();
            bundle.putString("mobile",mobile);
            intent.putExtras(bundle);
            setResult(1,intent);
            finish();
        }
        Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        UMShareAPI.get(this).onActivityResult(requestCode, resultCode, data);
        if(requestCode == 1)
        {
            String name = data.getExtras().getString("name");
            String password = data.getExtras().getString("password");
            editDengphone.setText(name);
            editDengpassword.setText(password);
        }
    }
}
 

4.登录布局

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:text="登录"
        android:gravity="center"
        />

    <EditText
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_margin="20dp"
        android:hint="请输入手机号"
        android:id="@+id/edit_dengphone"
        />

    <EditText
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_margin="20dp"
        android:hint="请输入密码"
        android:id="@+id/edit_dengpassword"
        />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:orientation="horizontal"
        >

        <Button
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="登录"
            android:id="@+id/btn_login"
            android:layout_margin="5dp"
            />

        <Button
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="注册"
            android:id="@+id/btn_zhuce"
            android:layout_margin="5dp"
            />

    </LinearLayout>

    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:text="QQ登录"
        android:id="@+id/btn_q"
        />

</LinearLayout>

5.注册布局

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:text="注册"
        android:gravity="center"
        />
    <EditText
        android:id="@+id/edit_zhucephone"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:hint="请输入手机号"
        android:layout_margin="10dp"
        />

    <EditText
        android:id="@+id/edit_zhucepassword"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:hint="请输入密码"
        android:layout_marginTop="20dp"
        android:layout_margin="10dp"
        />

    <Button
        android:id="@+id/btn_zhu"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_marginTop="50dp"
        android:text="注册"
        />

</LinearLayout>

6.注册主页面

public class ZhuceActivity extends BaseActivity<ZhucePresenter> implements ZhuceContract.View {

    @BindView(R.id.edit_zhucephone)
    EditText editZhucephone;
    @BindView(R.id.edit_zhucepassword)
    EditText editZhucepassword;
    @BindView(R.id.btn_zhu)
    Button btnZhu;
    private String s;
    private String s1;

    @Override
    public void setupActivityComponent(@NonNull AppComponent appComponent) {
        DaggerZhuceComponent //如找不到该类,请编译一下项目
                .builder()
                .appComponent(appComponent)
                .zhuceModule(new ZhuceModule(this))
                .build()
                .inject(this);
    }

    @Override
    public int initView(@Nullable Bundle savedInstanceState) {
        return R.layout.activity_zhuce; //如果你不需要框架帮你设置 setContentView(id) 需要自行设置,请返回 0
    }

    @Override
    public void initData(@Nullable Bundle savedInstanceState) {

    }

    @Override
    public void showLoading() {

    }

    @Override
    public void hideLoading() {

    }

    @Override
    public void showMessage(@NonNull String message) {
        checkNotNull(message);
        ArmsUtils.snackbarText(message);
    }

    @Override
    public void launchActivity(@NonNull Intent intent) {
        checkNotNull(intent);
        ArmsUtils.startActivity(intent);
    }

    @Override
    public void killMyself() {
        finish();
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }

    @OnClick(R.id.btn_zhu)
    public void onViewClicked() {

        s = editZhucephone.getText().toString();
        s1 = editZhucepassword.getText().toString();
        mPresenter.getzhu(s,s1);
    }

    @Override
    public void showData(Newszhuce newszhuce) {
        String code = newszhuce.getCode();
        String msg = newszhuce.getMsg();
        if(code.equals("0"))
        {
            Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
            Intent intent = new Intent();
            Bundle bundle = new Bundle();
            bundle.putString("name",s);
            bundle.putString("password",s1);
            intent.putExtras(bundle);
            setResult(1,intent);
            finish();
        }
        Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
    }
}
 

7.登录注册接口文档

//登录
    @GET("user/login?")
    Observable<NewsLogin> getLogin(@Query("mobile")String mobile,@Query("password")String password);

    //注册
    @GET("user/reg")
    Observable<Newszhuce> getZhu(@Query("mobile")String mobile,@Query("password")String password);
 

8.登录C层

public interface LoginContract {
    //对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息
    interface View extends IView {

        void showData(NewsLogin newsLogin);
    }

    //Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
    interface Model extends IModel {

        Observable<NewsLogin> responseMsg(String mobile,String password);
    }
}
 

登录M层

  @Override
    public Observable<NewsLogin> responseMsg(String mobile, String password) {
        MService mService = mRepositoryManager.obtainRetrofitService(MService.class);
        Observable<NewsLogin> login = mService.getLogin(mobile, password);
        return login;
    }

 

登录P层

@SuppressLint("CheckResult")
    public void getlogin(String name,String password)
    {
        Observable<NewsLogin> newsLoginObservable = mModel.responseMsg(name, password);
        newsLoginObservable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Consumer<NewsLogin>() {
            @Override
            public void accept(NewsLogin newsLogin) throws Exception {
                mRootView.showData(newsLogin);
            }
        }, new Consumer<Throwable>() {
            @Override
            public void accept(Throwable throwable) throws Exception {

            }
        });
    }

 

9.App层

public class App extends BaseApplication {

    private static App app;

    @Override
    public void onCreate() {
        super.onCreate();
        app = App.this;
        Fresco.initialize(this);
        UMConfigure.init(this,"5bc83db8f1f5568f6700037a"
                ,"umeng",UMConfigure.DEVICE_TYPE_PHONE,"");//58edcfeb310c93091c000be2 5965ee00734be40b580001a0
        PlatformConfig.setWeixin("wxdc1e388c3822c80b", "3baf1193c85774b3fd9d18447d76cab0");
        //豆瓣RENREN平台目前只能在服务器端配置
        PlatformConfig.setSinaWeibo("3921700954", "04b48b094faeb16683c32669824ebdad","http://sns.whalecloud.com");
        PlatformConfig.setYixin("yxc0614e80c9304c11b0391514d09f13bf");
        PlatformConfig.setQQZone("100424468", "c7394704798a158208a74ab60104f0ba");
        PlatformConfig.setTwitter("3aIN7fuF685MuZ7jtXkQxalyi", "MK6FEYG63eWcpDFgRYw4w9puJhzDl0tyuqWjZ3M7XJuuG7mMbO");
        PlatformConfig.setAlipay("2015111700822536");
        PlatformConfig.setLaiwang("laiwangd497e70d4", "d497e70d4c3e4efeab1381476bac4c5e");
        PlatformConfig.setPinterest("1439206");
        PlatformConfig.setKakao("e4f60e065048eb031e235c806b31c70f");
        PlatformConfig.setDing("dingoalmlnohc0wggfedpk");
        PlatformConfig.setVKontakte("5764965","5My6SNliAaLxEm3Lyd9J");
        PlatformConfig.setDropbox("oz8v5apet3arcdy","h7p2pjbzkkxt02a");
    }

    public static App getInstance()
    {
        return app;
    }
}
 

 

10.注册C层

public interface ZhuceContract {
    //对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息
    interface View extends IView {

        void showData(Newszhuce newszhuce);
    }

    //Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
    interface Model extends IModel {

        Observable<Newszhuce> responseMsg(String mobile,String password);
    }
}
 

注册M层

@Override
    public Observable<Newszhuce> responseMsg(String mobile, String password) {
        MService mService = mRepositoryManager.obtainRetrofitService(MService.class);
        Observable<Newszhuce> zhu = mService.getZhu(mobile, password);
        return zhu;
    }

 

注册P层

 @SuppressLint("CheckResult")
    public void getzhu(String name,String password)
    {
        Observable<Newszhuce> newszhuceObservable = mModel.responseMsg(name, password);
        newszhuceObservable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Consumer<Newszhuce>() {
            @Override
            public void accept(Newszhuce newszhuce) throws Exception {
                mRootView.showData(newszhuce);
            }
        }, new Consumer<Throwable>() {
            @Override
            public void accept(Throwable throwable) throws Exception {

            }
        });
    }

 

12.头像日期页面

public class SheZhiActivity extends AppCompatActivity {

    @BindView(R.id.simp_tou)
    SimpleDraweeView simpTou;
    @BindView(R.id.edit_riqi)
    EditText editRiqi;
    private Button btn_pai;
    private Button btn_bendi;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_she_zhi);
        ButterKnife.bind(this);
    }

    @OnClick({R.id.simp_tou, R.id.edit_riqi})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.simp_tou:
                AlertDialog.Builder builder = new AlertDialog.Builder(SheZhiActivity.this);
                //创建一个视图
                AlertDialog dialog = builder.create();
                //加载视图
                View view1 = View.inflate(SheZhiActivity.this, R.layout.zhao_item, null);
                dialog.setView(view1);
                btn_pai = view1.findViewById(R.id.btn_pai);
                btn_bendi = view1.findViewById(R.id.btn_bendi);
                btn_pai.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                        startActivityForResult(intent,1);
                    }
                });
                btn_bendi.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        //通过隐式跳转的方式
                        Intent intent = new Intent(Intent.ACTION_PICK);
                        //取出相册图片
                        intent.setType("image/*");
                        startActivityForResult(intent,2);
                    }
                });
                dialog.show();
                break;
            case R.id.edit_riqi:
                //不显示键盘
                new DatePickerDialog(SheZhiActivity.this, new DatePickerDialog.OnDateSetListener() {
                    @Override
                    public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                        editRiqi.setText(String.format("%d-%d-%d", year, monthOfYear + 1, dayOfMonth));
                    }
                }, 2000, 1, 2).show();
                break;
        }
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if(requestCode==1 && resultCode == RESULT_OK)
        {
            Bitmap bitmap = data.getParcelableExtra("data");
            //设置给图片
            simpTou.setImageBitmap(bitmap);
        }
        if(requestCode==2 && resultCode == RESULT_OK)
        {
            Uri uri = data.getData();
            simpTou.setImageURI(uri);
        }
    }
}
 

 

13.头像日期布局

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".SheZhiActivity">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="个人中心"
        android:gravity="center"
        android:textSize="25sp"
        />

    <View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="#909090"
        />

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="头像"
            android:layout_centerVertical="true"
            android:textSize="25sp"
            />

        <com.facebook.drawee.view.SimpleDraweeView
            android:layout_width="70dp"
            android:layout_height="70dp"
            android:layout_alignParentEnd="true"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            app:placeholderImage="@mipmap/ic_launcher"
            android:id="@+id/simp_tou"
            />

    </RelativeLayout>
    <View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="#909090"
        />
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="用户名"
            android:textSize="25sp"
            />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_alignParentRight="true"
            android:layout_alignParentEnd="true"
            android:text="lianhong."
            android:textSize="25sp"
            />

    </RelativeLayout>
    <View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="#909090"
        />
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="昵称"
            android:textSize="25sp"
            />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentEnd="true"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:text="脸红"
            android:textSize="25sp"
            />
    </RelativeLayout>
    <View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="#909090"
        />

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="性别"
            android:textSize="25sp"
            />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="女"
            android:textSize="25sp"
            android:layout_alignParentTop="true"
            android:layout_alignParentRight="true"
            android:layout_alignParentEnd="true"
            />
    </RelativeLayout>
    <View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="#909090"
        />

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="出生日期"
            android:textSize="25sp"
            />
        <EditText
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentEnd="true"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:layout_marginEnd="13dp"
            android:layout_marginRight="13dp"
            android:background="#fff"
            android:text="2018年8月23日"
            android:id="@+id/edit_riqi"
            />
    </RelativeLayout>
    <View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="#909090"
        />

</LinearLayout>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 6
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值