单击按钮时,我想转到另一个 xml 布局文件。所以我按照以下方式编写了开始新活动。
startActivity(new Intent(AndroidPHPConnectionDemo.this, MainActivity.class));
MainAcivity 类是,
public class MainActivity extends ListActivity implements FetchDataListener{
private ProgressDialog dialog;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initView();
}
private void initView() {
// show progress dialog
dialog = ProgressDialog.show(this, "", "Loading...");
String url = "http://10.0.2.2/new/newA.php";
FetchDataTask task = new FetchDataTask(this);
task.execute(url);
}
@Override
public void onFetchComplete(List<Application> data) {
// dismiss the progress dialog
if(dialog != null) dialog.dismiss();
// create new adapter
ApplicationAdapter adapter = new ApplicationAdapter(this, data);
// set the adapter to list
setListAdapter(adapter);
}
@Override
public void onFetchFailure(String msg) {
// dismiss the progress dialog
if(dialog != null) dialog.dismiss();
// show failure message
Toast.makeText(this, msg, Toast.LENGTH_LONG).show();
}
}
所以主activity类引用listview布局文件。调试时,执行 startactivity 行上方的代码。但问题是活动没有开始。这意味着我无法显示列表视图
请给出解决这个问题的答案