<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
android:id="@+id/editTextSMS"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ems="10"
android:lines="5"
android:scrollHorizontally="false"
android:inputType="textMultiLine"
android:textSize="43sp"
android:lineSpacingMultiplier="1.5"
android:maxLength="40"
android:letterSpacing="0.1"
/>
<LinearLayout
android:orientation="horizontal"
android:gravity="right"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
>
<TextView
android:id="@+id/textViewCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
android:textColor="#00FFFF"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="/80 바이트"
/>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:gravity="center_horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<Button
android:id="@+id/buttonSend"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onButtonSendClicked"
android:text="전송" />
/>
<Button
android:id="@+id/buttonClose"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onButtonDownClicked"
android:text="닫기" />
</LinearLayout>
</LinearLayout>
public class MainActivity extends AppCompatActivity {
EditText editTextSMS;
TextView textViewCount;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textViewCount = (TextView) findViewById(R.id.textViewCount);
editTextSMS = (EditText) findViewById(R.id.editTextSMS);
editTextSMS.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
textViewCount.setText(Integer.toString(s.toString().length()));
}
@Override
public void afterTextChanged(Editable s) {
}
});
}
public void onButtonSendClicked(View v) {
Toast toast = Toast.makeText(this, editTextSMS.getText(), Toast.LENGTH_LONG);
toast.show();
}
}
'기타 개발 > Android' 카테고리의 다른 글
도전!05 고객 정보 입력 화면의 구성 (0) | 2017.06.29 |
---|---|
도전!04 영업관리 앱용 화면 만들기 (0) | 2017.06.26 |
도전!03 로그인 화면과 메뉴 화면 간단히 만들기 (0) | 2017.06.26 |
도전!01 한 화면에 두 개의 이미지 뷰 배치하기 (0) | 2017.06.02 |
LinearLayout 정렬 (0) | 2017.06.01 |