안드로이드 EditText 부에 포커스 주고 키보드를 띄우자



1. 포커스 주기 : 레이아웃 xml  파일에서


EditText 뷰에         


<requestFocus />


를 추가해줌.


아래와 같이.




        <EditText

           android:id="@+id/messageText"

           android:layout_width="match_parent"

           android:layout_height="154dp"

           android:layout_alignParentLeft="true"

           android:layout_alignParentRight="true"

           android:layout_below="@+id/button1"

           android:background="#ffffff"

           android:ems="10"

           android:height="160dp"

           android:hint="회원들에게 전할 소식을 남기세요"

           android:inputType="textMultiLine"

           android:padding="10dp"

           android:textSize="16sp"

           android:textStyle="normal" >


        <requestFocus />

    </EditText>





2. 키보드 올리기(보이기) : EditText뷰가 포함되어 있는 액티비티 파일에서


private EditText editText;


editText = (EditText) findViewById(R.id.messageText);

editText.requestFocus();

//키보드 보이게 하는 부분

InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);

imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);





3. 키보드를 숨기려면?

InputMethodManager immhide = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE);

immhide.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);



블로그 이미지

엘로드넷

,

사각형 레이아웃의 위, 아래에 가는 선을 넣을려고 하는 것임



 




1. border.xml 파일을 아래처럼 만든다

파일위치 : /res/drawable-hdpi/border.xml



<?xml version="1.0" encoding="utf-8"?>

 <layer-list xmlns:android="http://schemas.android.com/apk/res/android">


<item> 

    <shape android:shape="rectangle">

      <solid android:color="#d7d7d7" /> 

    </shape>

  </item>   

    <item android:top="1dp" android:bottom="1dp">  

    <shape android:shape="rectangle"> 

      <solid android:color="#ffffff" />

    </shape>

  </item>    


 </layer-list> 


아래처럼 위, 아래, 왼쪽, 오른쪽..

android:top="1dp"     //위쪽
android:bottom="1dp"  //아래쪽
android:left="1dp"    //왼쪽
android:right="1dp"   //오른쪽



2. 적용할 레이아웃에 백그라운드로 적용한다.


파일위치 : /layout/activity_main.xml


<LinearLayout android:id="@+id/linear_layout5"

     android:layout_width="match_parent"

     android:layout_height="wrap_content"

     android:orientation="horizontal" 

     android:background="@drawable/border"

     

     >



위처럼 아래내용을 적용하고자 하는 레이아웃의 백그라운드에 추가해 주면 된다.


android:background="@drawable/border"




3. 끝.





블로그 이미지

엘로드넷

,

String test = null;



Case1. null 또는 빈 값 체크


if(test == null || test.equals("") || test.equals(null)){


//To do

}



Case2. 빈 값 체크


if("".equals(test){

//To do

}



if(TextUtils.isEmpty(test){


//To do

}



블로그 이미지

엘로드넷

,

안드로이드 해상도별 아이콘 사이즈


Low Density Per Inch (ldpi)                       36 x 36 pixel

Medium Density Per Inch (mdpi)                 48 x 48 pixel

High Density Per Inch (hdpi)                     72 x 72 pixel

eXtra High Density Per Inch (xhdpi)             96 x 96 pixel

eXtra eXtra High Density Per Inch (xxhdpi)    144 x 144 pixel





배포시 아이콘


  1. 고해상도 아이콘 : 512*512
  2. Android TV 용 : 320*180
  3. 그래픽 이미지 : 1024*500


블로그 이미지

엘로드넷

,