예제 #1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    listView = (AsymmetricGridView) findViewById(R.id.listView);

    setSupportActionBar(toolbar);

    ActionBar actionBar = getSupportActionBar();
    actionBar.setHomeAsUpIndicator(R.drawable.ic_menu);
    actionBar.setDisplayHomeAsUpEnabled(true);

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    if (navigationView != null) {
      setupDrawerContent(navigationView);
    }

    if (USE_CURSOR_ADAPTER) {
      if (savedInstanceState == null) {
        adapter = new DefaultCursorAdapter(this, demoUtils.moarItems(50));
      } else {
        adapter = new DefaultCursorAdapter(this);
      }
    } else {
      if (savedInstanceState == null) {
        adapter = new DefaultListAdapter(this, demoUtils.moarItems(50));
      } else {
        adapter = new DefaultListAdapter(this);
      }
    }

    listView.setRequestedColumnCount(3);
    listView.setRequestedHorizontalSpacing(Utils.dpToPx(this, 3));
    listView.setAdapter(getNewAdapter());
    listView.setDebugging(true);
    listView.setOnItemClickListener(this);
  }
예제 #2
0
 private void setNumColumns(int numColumns) {
   listView.setRequestedColumnCount(numColumns);
   listView.determineColumns();
   listView.setAdapter(getNewAdapter());
 }