티스토리 뷰
●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 함수 사용해도 됨.
'프로그래밍 > Android' 카테고리의 다른 글
Android] Adb connection Error 원인 (0) | 2014.08.08 |
---|---|
Android] listener 선언/생성 방법 4가지 (0) | 2014.02.07 |
Android] intent / intent-filter (0) | 2014.02.07 |
Android] Error The constructor .... is undefined (0) | 2014.02.06 |
Android] Adb connection Error (0) | 2014.02.05 |