正确的代码,但错误发生了

时间:2014-05-11 03:23:16

标签: navigation drawer

谁可以解释这些代码?特别是粗体代码

import android.widget.ListView;

public class MainActivity extends Activity {

private String[] mPlanetTitles;
private DrawerLayout mDrawerLayout;
private ListView mDrawerList;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    **mPlanetTitles = getResources().getStringArray(R.array.planets_array);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerList = (ListView) findViewById(R.id.left_drawer);**

    // Set the adapter for the list view
    **mDrawerList.setAdapter(new ArrayAdapter<String>(this,
            R.layout.drawer_list_item, mPlanetTitles));
    // Set the list's click listener
    mDrawerList.setOnItemClickListener(new DrawerItemClickListener());**

}

0 个答案:

没有答案