Activity
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu1:
break;
case R.id.menu2:
startActivity(new Intent(MainActivity.this, Main2Activity.class));
break;
case android.R.id.home:
super.onBackPressed();
default:
break;
}
return true;
}
刷新加载
//封装一个方法
private void squre() {
map = new HashMap<>();
map.put("page",page+"");
map.put("count","20");
moviePresenter.lb(Api.ZMOVIE, map);
}
//刷新
@Override
public void onRefresh() {
page=1;
Toast.makeText(MainActivity.this,"刷新成功",Toast.LENGTH_SHORT).show();
squre();
xrv.refreshComplete();
}
//加载
@Override
public void onLoadMore() {
page++;
Toast.makeText(MainActivity.this,"已无更多数据",Toast.LENGTH_SHORT).show();
squre();
xrv.loadMoreComplete();
}
//xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toob"
app:navigationIcon="@drawable/icon_fh"
android:background="#fcc">
<TextView
android:id="@+id/toob_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="电影商城"
android:textSize="18sp"/>
</android.support.v7.widget.Toolbar>
//菜单文件
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/menu1"
android:title="热门电影"
app:showAsAction="withText"/>
<item
android:id="@+id/menu2"
android:title="正在上映"
app:showAsAction="withText"/>
</menu>
//在style文件下改变activity的自带的按钮
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">