메뉴 건너뛰기

조회 수 6905 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄 첨부
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄 첨부

MainActivity 소스

 

public class MainActivity extends Activity {

 

@Override

protected void onCreate(Bundle savedInstanceState) {

  super.onCreate(savedInstanceState);

  setContentView(R.layout.activity_main);

 

  if (savedInstanceState == null) {

   getFragmentManager().beginTransaction()

     .add(R.id.container, new PlaceholderFragment()).commit();

  }

}

 

public void sendMessage(View view) {

  Intent intent = getIntent();

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

  String message = editText.getText().toString();

  Toast.makeText(this,message,Toast.LENGTH_SHORT).show();

}




=====================================================================================



프레그먼트_메인.xml 소스

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.test.MainActivity$PlaceholderFragment" >

    <EditText 
        android:id="@+id/input"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:hint="@string/nameInput"
        />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignTop="@+id/input"
        android:layout_marginLeft="21dp"
        android:layout_toRightOf="@+id/input"
        android:text="@string/send" 
        android:onClick="sendMessage"/>

</RelativeLayout>


=====================================================================================



strings.xml 소스

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

    <string name="app_name">Test</string>
    <string name="action_settings">Settings</string>
    <string name="nameInput">이름을 입력하세요</string>
    <string name="send">전송</string>

</resources>


=====================================================================================

실행화면








  1. [하이브리드앱] 링크를 웹뷰가 아닌 새로운 브라우저에서 열기

    Date2021.09.30 Views295
    Read More
  2. 간단한 mp3 플레이어 만들기 , 음악넣기 , 노래재생

    Date2016.06.07 Views14636
    Read More
  3. 구글맵 snippet을 두줄이상으로 구현하기

    Date2020.12.14 Views486
    Read More
  4. 구글맵으로 GPS 현재위치 실시간 연동하기

    Date2020.12.14 Views2487
    Read More
  5. 내가 입력한 글자 Toast로 나오게 하기

    Date2015.07.26 Views6905
    Read More
  6. 네트워크 상태 변화 감지하기(BroadcastReceiver 사용)

    Date2015.07.16 Views9947
    Read More
  7. 네트워크 연결 상태 및 3G/WIFI 연결상태 체크하기

    Date2016.03.18 Views7144
    Read More
  8. 네트워크를 통해 받은 이미지를 파일로 저장하고, 크기 조절해서 불러오기

    Date2015.07.16 Views6160
    Read More
  9. 노티피케이션(Notification) 사용법 / Notification.Builder , NotificationManager

    Date2016.06.10 Views13474
    Read More
  10. 다운로드 매니저(DownloadManager)에 대해 알아보자

    Date2015.07.01 Views9247
    Read More
  11. 맵에 오버레이 추가하여 아이템 넣어보기

    Date2014.08.28 Views6481
    Read More
  12. 문자를 음성으로 변환(TTS)에 대해 알아보자

    Date2015.07.01 Views7771
    Read More
  13. 버튼 누르면 이미지 바꾸기

    Date2015.07.26 Views6622
    Read More
  14. 버튼 생성, 이벤트 처리

    Date2021.03.31 Views237
    Read More
  15. 버튼 이벤트

    Date2021.03.31 Views210
    Read More
  16. 버튼 이벤트 추가하기

    Date2021.03.31 Views195
    Read More
  17. 버튼(Button) 패딩 제거

    Date2016.06.10 Views7662
    Read More
  18. 블루투스 및 비콘 관련 정리

    Date2015.07.26 Views10834
    Read More
  19. 블루투스(Bluetooth) 통신에 대해 알아보자

    Date2015.07.01 Views7985
    Read More
  20. 블루투스(Bluetooth) 통신에 대해 알아보자

    Date2015.07.26 Views14055
    Read More
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 13 Next
/ 13

하단 정보를 입력할 수 있습니다

© k2s0o1d4e0s2i1g5n. All Rights Reserved