只需复制并粘贴它。
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// navdra = getResources().getStringArray(R.array.navdra);
listView = (ListView) findViewById(R.id.drawerlist);
myAdapter = new MyAdapter(this);
// listView.setAdapter(new ArrayAdapter<String>(this,
// android.R.layout.simple_expandable_list_item_1, navdra));
listView.setAdapter(myAdapter);
listView.setOnItemClickListener(this);
drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
drawerListner = new ActionBarDrawerToggle(this, drawerLayout,
R.drawable.ic_drawer, R.string.dopen, R.string.dclose);
/*
* @Override public void onDrawerOpened(View drawerView) {
* Toast.makeText(MainActivity.this, "Open", Toast.LENGTH_SHORT)
* .show(); }
*
* @Override public void onDrawerClosed(View drawerView) {
* Toast.makeText(MainActivity.this, "Close", Toast.LENGTH_SHORT)
* .show(); } }
*/
drawerLayout.setDrawerListener(drawerListner);
getSupportActionBar().setHomeButtonEnabled(true);
getActionBar().setDisplayHomeAsUpEnabled(true);
Button csv = (Button) findViewById(R.id.cs);
csv.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(v.getContext(), Semester.class);
startActivityForResult(intent, 0);
}
});
Button cal = (Button) findViewById(R.id.cal);
cal.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(v.getContext(), Calculator.class);
startActivityForResult(intent, 0);
}
});
Button iq = (Button) findViewById(R.id.interviewquestion);
iq.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(v.getContext(),
InterviewQuestion.class);
startActivityForResult(intent, 0);
}
});
Button cg = (Button) findViewById(R.id.program);
cg.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent = new Intent(v.getContext(), Programs.class);
startActivityForResult(intent, 0);
}
});
Button abt = (Button) findViewById(R.id.about);
abt.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getApplicationContext(), "PKlabs!!!",
Toast.LENGTH_SHORT).show();
// Intent intent = new Intent
// (v.getContext(),InterviewQuestion.class);
// startActivityForResult(intent,0);
}
});
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
// TODO Auto-generated method stub
super.onConfigurationChanged(newConfig);
drawerListner.onConfigurationChanged(newConfig);
}
@Override
protected void onPostCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onPostCreate(savedInstanceState);
drawerListner.syncState();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuItem item = menu.add("share"); // your desired title here
item.setIcon(R.drawable.share_icon); // your desired icon here
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
item.setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
shareintent = new Intent(android.content.Intent.ACTION_SEND);
shareintent.setType("text/plain");
String shareBody = "Here is the share content body";
shareintent.putExtra(android.content.Intent.EXTRA_SUBJECT,
"Subject Here");
shareintent.putExtra(Intent.EXTRA_TEXT, "Hi there");
startActivity(Intent.createChooser(shareintent, "Share via"));
return true;
}
});
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
if (drawerListner.onOptionsItemSelected(item)) {
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
if (position == 0) {
Uri uri = Uri
.parse("https://2ce74af0d8de8783b91cdd315eeba0340a4b9277.googledrive.com/host/0B2sDUzNeIK0KODB0ZDRMVjFPaFE/Jobs.html");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
} else if (position == 1) {
Intent intent = new Intent(this, Careerguid.class);
startActivityForResult(intent, 0);
} else if (position == 2) {
Toast.makeText(this, "Coming Soon!!!", Toast.LENGTH_LONG).show();
}
// }
else if (position == 3) {
Uri uri = Uri.parse("http://www.google.com");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}
else if (position == 4) {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("plain/text");
final PackageManager pm = getPackageManager();
final List<ResolveInfo> matches = pm.queryIntentActivities(intent,
0);
ResolveInfo best = null;
for (final ResolveInfo info : matches)
if (info.activityInfo.packageName.endsWith(".gm")
|| info.activityInfo.name.toLowerCase().contains(
"gmail"))
best = info;
if (best != null)
intent.setClassName(best.activityInfo.packageName,
best.activityInfo.name);
intent.putExtra(Intent.EXTRA_EMAIL,
new String[] { "laboratorypk@gmail.com" });
intent.putExtra(Intent.EXTRA_SUBJECT, "Query/Feedback");
intent.putExtra(Intent.EXTRA_TEXT, "");
startActivity(Intent.createChooser(intent, ""));
}
if (position == 5) {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("plain/text");
final PackageManager pm = getPackageManager();
final List<ResolveInfo> matches = pm.queryIntentActivities(intent,
0);
ResolveInfo best = null;
for (final ResolveInfo info : matches)
if (info.activityInfo.packageName.endsWith(".gm")
|| info.activityInfo.name.toLowerCase().contains(
"gmail"))
best = info;
if (best != null)
intent.setClassName(best.activityInfo.packageName,
best.activityInfo.name);
intent.putExtra(Intent.EXTRA_EMAIL,
new String[] { "laboratorypk@gmail.com" });
intent.putExtra(Intent.EXTRA_SUBJECT, "PC Games");
intent.putExtra(Intent.EXTRA_TEXT,
"Hey! I need PC Games pls share the List.");
startActivity(Intent.createChooser(intent, ""));
}
drawerLayout.closeDrawers();
selectItem(position);
}
public void selectItem(int position) {
// TODO Auto-generated method stub
listView.setItemChecked(position, true);
}
public void setTitle(String title) {
getSupportActionBar().setTitle(title);
}
private Toast toast;
private long lastBackPressTime = 0;
@Override
public void onBackPressed() {
if (this.lastBackPressTime < System.currentTimeMillis() - 4000) {
toast = Toast.makeText(this, "Press back again to exit",
Toast.LENGTH_LONG);
toast.show();
this.lastBackPressTime = System.currentTimeMillis();
drawerLayout.closeDrawers();
} else {
if (toast != null) {
toast.cancel();
}
super.onBackPressed();
}
}
}
class MyAdapter extends BaseAdapter {
private Context context;
String[] navlist;
int[] images = { R.drawable.job, R.drawable.career, R.drawable.project,
R.drawable.facebook, R.drawable.mail, R.drawable.games };
public MyAdapter(Context context) {
this.context = context;
navlist = context.getResources().getStringArray(R.array.navdra);
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return navlist.length;
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return navlist[position];
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View row = null;
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
row = inflater.inflate(R.layout.customrow, parent, false);
}
else {
row = convertView;
}
TextView titleTextView = (TextView) row.findViewById(R.id.textView11);
ImageView titleImageView = (ImageView) row
.findViewById(R.id.imageView1);
titleTextView.setText(navlist[position]);
titleImageView.setImageResource(images[position]);
return row;
}
}