当前位置 : 主页 > 手机开发 > android >

View 层

来源:互联网 收集:自由互联 发布时间:2021-06-11
package com.test.mvp.mvpdemo.mvp.v1.view; import android.app.ProgressDialog;import android.os.Bundle;import android.os.Handler;import android.support.v7.app.AppCompatActivity;import android.widget.TextView;import android.widget.Toast; impor

package com.test.mvp.mvpdemo.mvp.v1.view; import android.app.ProgressDialog;import android.os.Bundle;import android.os.Handler;import android.support.v7.app.AppCompatActivity;import android.widget.TextView;import android.widget.Toast; import com.test.mvp.mvpdemo.R;import com.test.mvp.mvpdemo.mvp.v1.MainContract;import com.test.mvp.mvpdemo.mvp.v1.presenter.MainPresenter; /** * MVP 的写法,Version 1: 基础写法 */public class MainActivity extends AppCompatActivity implements MainContract.IMainView { private TextView tv; private MainPresenter mPresenter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); initViews(); mPresenter = new MainPresenter(this); mPresenter.handlerData(); } private void initViews() { tv = findViewById(R.id.tv); } @Override public void showDialog() { ProgressDialog dialog = new ProgressDialog(this); dialog.show(); new Handler().postDelayed(new Runnable() { @Override public void run() { dialog.dismiss(); } }, 1500); } @Override public void succes(String content) { runOnUiThread(new Runnable(http://www.amjmh.com/v/) { @Override public void run() { Toast.makeText(MainActivity.this, "" + content, Toast.LENGTH_SHORT).show(); tv.setText(content); } }); }}---------------------

网友评论