기본 콘텐츠로 건너뛰기

7월, 2015의 게시물 표시

[android] listview 구현하기

<main.xml> android:divider -> 리스트의 셀사이의 선색 android:dividerHeight -> 리스트의 셀사이 선 두께 1 2 3 4 5 6 7 <ListView      android:id="@+id/list"      android:layout_width="fill_parent"      android:layout_height="wrap_content"      android:divider="#ff0000"      android:dividerHeight="1dp" > </ListView> cs <MainActivity.java> 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 ArrayList<String> m_arr;          @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentV...

[android] login dialog popup 구현 / Activity를 dialog로 만들기 / custom dialog

login dialog (custom dialog) 만들기 Activity를 dialog로 보이기. Manifest에서 android:theme="@android:style/Theme.Holo.Light.Dialog" 1 2 < activity android:name = ".ActivityDialog"     android:theme = "@android:style/Theme.Holo.Light.Dialog" > < / activity > cs login dialog 만드는 자세한 소스는 추후 추가.

[android] 이클립스 줄 넘버, 줄 번호 (eclipse line number)

사진과 같이 eclipse에서 왼쪽 줄번호 나타내는 방법. Window > Preferences > General > Editors > Text Editors > Show line numbers 체크

[android] list dialog 구현하기

리스트 형태의 dialog를 구현하는 방법. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 CharSequence info[]  =   new  CharSequence[] { "내정보" ,  "로그아웃"  };         AlertDialog.Builder builder  =   new  AlertDialog.Builder( this );         builder.setTitle( "제목" );         builder.setItems(info,  new  DialogInterface.OnClickListener() {             @Override              public   void  onClick(DialogInterface dialog,  int  which) {                  switch (which)    ...

[android] startActivity와 startActivityForResult의 차이점

public void  startActivity   ( Intent  intent) startActivity(new Intent(MainActivity.this, secondActivity.class)); startActivity는 액티비티를 호출하는 함수. 일방형 다음 액티비티로 필요한 값을 전달해줄 수 있지만 다시 값을 전달 받을 수는 없다. public void  startActivityForResult   ( Intent  intent, int requestCode) Intent intent = new Intent( MainActivity .this,  secondActivity .class); intent.putExtra("test", data); startActivityForResult( intent , 10); startActivityForResult도 액티비티를 호출하는 함수. 쌍방형 값을 전달하고 또 전달 받을 수 있다. 위처럼 MainActivity -> secondActivity로 이동후 다시 secondActivity -> MainActivity로 이동할 때 setResult를 사용한다. public final void  setResult   (int resultCode,  Intent  data) Intent intent = new Intent(); intent.putExtra("test", data); setResult(RESULT_OK, intent); finish(); secondActivity에서 다음과 같이 사용하여 data를 넘기면 MainActivity의 onActivityResult함수에서 데이터 값을 받아서 사용 할 수 있다. protected void  onActivityResult   (i...

[android] 액션 버튼 아이콘 변경 (Action item icon)

invalidateOptionsMenu(); 를 사용하여 onPrepareOptionsMenu함수를 호출 할 수 있다는 점을 이용. bchange 의 여부에 따라서 아이콘을 변경할 수 있다. 1 2 3 4 5 6 7 8 9 10 11 12 @Override      public   void  onPrepareOptionsMenu(Menu menu) {          if (bchange)         {             menu.findItem(R.id.menu_test).setIcon(R.drawable.btngrid);         }          else         {             menu.findItem(R.id. menu_test ).setIcon(R.drawable.btnlist);         }          super .onPrepareOptionsMenu(menu);     } Color...