프로그래밍

안드로이드 자주쓰는 코드

roquen4145 2018. 7. 30.


* onClickListener 만들기


TextView sampleTextView;


sampleTextView = (TextView) findViewById(R.id.textview_id);  // 주로 onCreate 함수 안에 선언


sampleTextView.setOnClickListener(new View.OnClickListener(){

@Override

public void onClick( View v) {

  // Click 했을 때 작업

}

});








* LinearLayout 기본 골격


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

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:app="http://schemas.android.com/apk/res-auto"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:orientation="vertical"

    android:background="@color/color_ffffff" >


</LinearLayout>



* Layout 내 컨텐츠 정렬


android:gravity="center" // 레이아웃에 추가 , top, bottom , left, right, center_horizontal, center_vertical 등

'프로그래밍' 카테고리의 다른 글

Vagrant Study  (0) 2021.05.10
하루 10분 공부하기 자료구조  (0) 2019.01.02
우분투 18.04 세팅  (0) 2018.07.23
머신러닝 공부  (2) 2017.08.08
VMware Player에서 Ubuntu 세팅  (0) 2017.07.20

댓글