import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView; public class MainActivity extends Activity implements MainImplement,
View.OnClickListener {
private Button btn;
private TextView tv_view;
private MainModel mModel;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mModel = new MainModel();
btn = (Button) this.findViewById(R.id.btn);
tv_view = (TextView) this.findViewById(R.id.tv_view);
btn.setOnClickListener(this);
}
@Override
public void loadData() {
mModel.loadData(tv_view);
} @Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.btn:
loadData();
break; default:
break;
}
}
}
public interface MainImplement {
public void loadData();
}
import android.widget.TextView;
public class MainModel {
public void loadData(TextView tv_view) {
tv_view.setText("MVC模式在Android中的应用,获取到的Model中处理的数据");
}
}