1.侧边栏是一个抽屉效果
2viewpager是一个滑动的
3.顶部的类似viewpagerindecater 升级
4.自动轮播图
5.listview展示
6.点击进去详情数据展示 打开关闭
7.下载退出,两个状态是同步的 ,暂停,点击下载可以继续下载,点击安装,
始终有问题,即使运行别人写好的代码也不能替换actionBar的图标,更不能实现动态效果….从来没有实现过,不知道问题出在哪?
但是在查资料的时候看到很多
ActionBar自定义布局
不同fragment下actionBar不同状态
L bar
最新的 Toolbar
更改ActionBar的up图标,但是就没有Toggle的动态效果了
主界面的布局见 DrawLayout
public class MainActivity extends AppCompatActivity {
private ActionBar mActionBar;
private DrawerLayout mDrawerLayout; // 抽屉
private ActionBarDrawerToggle mDrawerToggle; // 抽屉开关
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawerlayout);
// 初始化actionbar
initActionBar();
}
private void initActionBar() {
mActionBar = getSupportActionBar();
// 设置title
mActionBar.setTitle("GooglePlay");
// 设置图标
mActionBar.setIcon(R.mipmap.ic_launcher);
mActionBar.setDisplayShowHomeEnabled(true);
// 显示up按钮
mActionBar.setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);//设置返回键可用
mActionBar.setHomeAsUpIndicator(R.mipmap.ic_drawer_am);
// 创建开关
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
R.mipmap.ic_drawer_am,
R.string.openDrawerContentDescRes,
R.string.closeDrawerContentDescRes);
// 后面两个String其实没什么意思,但是一定要写
// 设置drawerlayout的监听
//实现动画
//ActionBarDrawerToggle implements DrawerLayout.DrawerListener
mDrawerLayout.setDrawerListener(mDrawerToggle);
}
/**
*使用时覆盖这个方法,图标就会伸缩了
* When using the ActionBarDrawerToggle, you must call it during
* onPostCreate() and onConfigurationChanged()...
*/
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
// Sync the toggle state after onRestoreInstanceState has occurred.
mDrawerToggle.syncState();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
// 打开或关闭抽屉
boolean selected = mDrawerToggle.onOptionsItemSelected(item);
/*
* This method should be called by your <code>Activity</code>'s
* {@link Activity#onOptionsItemSelected(android.view.MenuItem) onOptionsItemSelected} method.
* If it returns true, your <code>onOptionsItemSelected</code> method should return true and
* skip further processing.
*
* @param item the MenuItem instance representing the selected menu item
* @return true if the event was handled and further processing should not occur
*/
if (selected) {
return true;//防止影响下面的
}
break;
default:
break;
}
return super.onOptionsItemSelected(item);
}
}