티스토리 뷰

●AlertDialog

AlertDialog.Builder dlg = new Builder(MainActivity.this);
     dlg.setMessage("띄울 메시지 내용");
     dlg.setNegativeButton("확인", null);
     dlg.show();

--Title 등 기타 설정 가능(setTitle...등)

 

●Menu와 MenuItem Click event

@Override
 public boolean onCreateOptionsMenu(Menu menu) {
  // Inflate the menu; this adds items to the action bar if it is present.
  getMenuInflater().inflate(R.menu.main, menu); // 리소스에 담긴 내용으로 세팅
  return true;
 }

-- 리소스로 추가하는 경우

 

 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
  // TODO Auto-generated method stub

  switch (item.getItemId()) {
  case R.id.next_activity:  //next_activity는 내가 지정한 리소스 id임

  // 메뉴클릭시 하고자 하는 기능을 넣으면 됨. 글쓴이는 SubActivity로 intent 전환하는 테스트를 함
   Intent intent = new Intent(MainActivity.this, SubActivity.class);
   startActivity(intent);
   break;
  }
  return super.onOptionsItemSelected(item);
 }

 

●Toast

   Toast.makeText(getApplicationContext(), "띄울 메시지 내용",
   Toast.LENGTH_SHORT).show();

 

●Log

   String TAG = "TagName";

   Log.v(TAG, "Text");

   또는 그냥  print 함수 사용해도 됨.

 

댓글
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30