Android FrameLayout 예제

Programming/Android 2014. 1. 12. 11:36 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

Android FrameLayout 예제


MainAcitivity.java


 

package com.example.test2;


import android.app.Activity;

import android.os.Bundle;

import android.view.Menu;

import android.view.View;

import android.view.View.OnClickListener;

import android.widget.Button;


public class MainActivity extends Activity implements OnClickListener {


Button button1;

Button button2;

Button button3;

    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);

        button1 = (Button)findViewById(R.id.button1);

        button2 = (Button)findViewById(R.id.button2);

        button3 = (Button)findViewById(R.id.button3);

        

        button1.setOnClickListener(this);

        button2.setOnClickListener(this);

        button3.setOnClickListener(this);

    }



    @Override

    public boolean onCreateOptionsMenu(Menu menu) {

        // Inflate the menu; this adds items to the action bar if it is present.

        getMenuInflater().inflate(R.menu.main, menu);

        return true;

    }



@Override

public void onClick(View v) {

View temp;

// TODO Auto-generated method stub

if( v.getId() == R.id.button1 )

{

temp = (View)findViewById(R.id.tab1);

temp.setVisibility(View.VISIBLE);

temp = (View)findViewById(R.id.tab2);

temp.setVisibility(View.INVISIBLE);

temp = (View)findViewById(R.id.tab3);

temp.setVisibility(View.INVISIBLE);

}

else if( v.getId() == R.id.button2 )

{


temp = (View)findViewById(R.id.tab2);

temp.setVisibility(View.VISIBLE);

temp = (View)findViewById(R.id.tab1);

temp.setVisibility(View.INVISIBLE);

temp = (View)findViewById(R.id.tab3);

temp.setVisibility(View.INVISIBLE);

}

else if( v.getId() == R.id.button3 )

{


temp = (View)findViewById(R.id.tab3);

temp.setVisibility(View.VISIBLE);

temp = (View)findViewById(R.id.tab1);

temp.setVisibility(View.INVISIBLE);

temp = (View)findViewById(R.id.tab2);

temp.setVisibility(View.INVISIBLE);

}

}

    

}




activity_main.xml



 

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

    xmlns:tools="http://schemas.android.com/tools"

    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=".MainActivity" >


    <Button

        android:id="@+id/button1"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:layout_alignParentLeft="true"

        android:layout_alignParentTop="true"

        android:text="Button1" />


    <Button

        android:id="@+id/button3"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:layout_alignBaseline="@+id/button2"

        android:layout_alignBottom="@+id/button2"

        android:layout_toRightOf="@+id/button2"

        android:text="Button3" />


    <Button

        android:id="@+id/button2"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:layout_alignBaseline="@+id/button1"

        android:layout_alignBottom="@+id/button1"

        android:layout_toRightOf="@+id/button1"

        android:text="Button2" />


    <FrameLayout

        android:layout_width="match_parent"

        android:layout_height="match_parent"

        android:layout_below="@+id/button2">


        <ImageView

            android:id="@+id/tab1"

            android:layout_width="match_parent"

            android:layout_height="match_parent"

            android:src="@drawable/image" />


        <LinearLayout

            android:id="@+id/tab2"

            android:visibility="invisible"

            android:layout_width="match_parent"

            android:layout_height="match_parent"

            android:orientation="vertical" >


            <Button

                android:layout_width="wrap_content"

                android:layout_height="wrap_content"

                android:text="Button" />


            <Button

                android:layout_width="wrap_content"

                android:layout_height="wrap_content"

                android:text="Button" />

        </LinearLayout>


        <LinearLayout

            android:id="@+id/tab3"

            android:visibility="invisible"

            android:layout_width="match_parent"

            android:layout_height="match_parent"

            android:orientation="vertical" >


            <TableLayout

                android:layout_width="match_parent"

                android:layout_height="match_parent" >


                <TableRow>


                    <Button

                        android:layout_width="wrap_content"

                        android:layout_height="wrap_content"

                        android:text="Button" />


                    <Button

                        android:layout_width="wrap_content"

                        android:layout_height="wrap_content"

                        android:text="Button" />


                    <Button

                        android:layout_width="wrap_content"

                        android:layout_height="wrap_content"

                        android:text="Button" />

                </TableRow>


                <TableRow>


                    <Button

                        android:layout_width="wrap_content"

                        android:layout_height="wrap_content"

                        android:text="Button" />


                    <Button

                        android:layout_width="wrap_content"

                        android:layout_height="wrap_content"

                        android:text="Button" />


                    <Button

                        android:layout_width="wrap_content"

                        android:layout_height="wrap_content"

                        android:text="Button" />

                </TableRow>

            </TableLayout>

        </LinearLayout>

    </FrameLayout>


</RelativeLayout>


336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.



안드로이드 폰 위치 기록 확인

https://maps.google.com/locationhistory/



안드로이드 폰 현재 위치 확인

https://www.google.com/android/devicemanager

336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

#include<stdio.h>

void printMenu(); 


void Rent(); 

void Return(); 


int main(void)

{

int selectedMenu;

printMenu();

scanf("%d", &selectedMenu);

if( selectedMenu == 1)

{

// Rent

Rent(); 

}

else if( selectedMenu == 2 )

{

// Return

Return(); 

}


    return 0;

}


void printMenu()

{

printf("==============\n");

printf("=1. 대     여=\n");

printf("==============\n");

printf("=2. 반     납=\n");

printf("==============\n");


}

void Rent()

{

FILE* stream;

char inputString[30];

stream = fopen("VideoList.txt","r");

printf("==============\n");

printf("= 대       여=\n");

printf("==============\n");

// 대여 가능 비디오 목록

// Input

while(!feof(stream))

{

fgets(inputString, 30, stream);

puts(inputString);

}

fclose(stream);

fflush(stdin);

gets(inputString);

stream = fopen("RentVideoList.txt","a");

fputs(inputString, stream);

fclose(stream);

// Add RentVideoList.txt

}

void Return()

{

printf("==============\n");

printf("= 반       납=\n");

printf("==============\n");

// 반납 가능 비디오 목록

// Input


// Remove RentVideoList.txt

}

336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

#include<stdio.h>

void printMenu(); 


void Rent(); 

void Return(); 


int main(void)

{

int selectedMenu;

printMenu();

scanf("%d", &selectedMenu);

if( selectedMenu == 1)

{

// Rent

Rent(); 

}

else if( selectedMenu == 2 )

{

// Return

Return(); 

}


    return 0;

}


void printMenu()

{

printf("==============\n");

printf("=1. 대     여=\n");

printf("==============\n");

printf("=2. 반     납=\n");

printf("==============\n");


}

void Rent()

{

printf("==============\n");

printf("= 대       여=\n");

printf("==============\n");

// 대여 가능 비디오 목록

// Input


// Add RentVideoList.txt

}

void Return()

{

printf("==============\n");

printf("= 반       납=\n");

printf("==============\n");

// 반납 가능 비디오 목록

// Input


// Remove RentVideoList.txt

}

JAVA 쿵쿵따 게임 #2 중복 탐지

Programming/JAVA,JSP 2014. 1. 9. 17:12 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

package com.tistory.tansanc;

 

import java.util.HashSet;

import java.util.Scanner;

 

public class User {

   public static void main(String[] args) {

       Scanner sc = new Scanner(System.in);

       String[] word = {"기러기", "기차표","스피커"};

       String oldWord = word[

                         (int)(Math.random()*3)  ];

       HashSet<String> hs = new HashSet<String>();

      

       hs.add(oldWord);

      

       System.out.println("제시어 : " + oldWord);   

       String newWord = sc.nextLine();

      

       if( ! hs.add(newWord) )

       {

          System.err.println("중복 발생!");

       }

      

       if( oldWord.charAt(2) ==

             newWord.charAt(0) )

       {

          System.out.println("OK");

       }

       else

       {

          System.err.println("ERROR");

       }

       while(true)

       {

          oldWord = newWord;

          newWord = sc.nextLine();

         

          if( ! hs.add(newWord) )

          {

             System.err.println("중복 발생!");

          }

         

          if( oldWord.charAt(2) ==

                 newWord.charAt(0) )

          {

             System.out.println("OK");

          }

          else

          {

             System.out.println("ERROR");

          }

       }        

   }

}

 

'Programming > JAVA,JSP' 카테고리의 다른 글

JAVA 가계부 #2  (0) 2014.01.14
JAVA 가계부  (0) 2014.01.14
JAVA 쿵쿵따 게임  (0) 2014.01.09
JAVA 제네릭 컬렉션 실습  (1) 2014.01.09
JAVA 객체지향 핵심 이론  (0) 2014.01.07

JAVA 쿵쿵따 게임

Programming/JAVA,JSP 2014. 1. 9. 17:07 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

package com.tistory.tansanc;

 

import java.util.Scanner;

 

public class User {

   public static void main(String[] args) {

       Scanner sc = new Scanner(System.in);

       String[] word = {"기러기", "기차표","스피커"};

       String oldWord = word[

                         (int)(Math.random()*3)  ];

       System.out.println("제시어 : " + oldWord);

       String newWord = sc.nextLine();    

       if( oldWord.charAt(2) ==

             newWord.charAt(0) )

       {

          System.out.println("OK");

       }

       else

       {

          System.out.println("ERROR");

       }

       while(true)

       {

          oldWord = newWord;

          newWord = sc.nextLine();     

          if( oldWord.charAt(2) ==

                 newWord.charAt(0) )

          {

             System.out.println("OK");

          }

          else

          {

             System.out.println("ERROR");

          }

       }        

   }

}

'Programming > JAVA,JSP' 카테고리의 다른 글

JAVA 가계부  (0) 2014.01.14
JAVA 쿵쿵따 게임 #2 중복 탐지  (0) 2014.01.09
JAVA 제네릭 컬렉션 실습  (1) 2014.01.09
JAVA 객체지향 핵심 이론  (0) 2014.01.07
JAVA 행렬 곱셈 결과  (0) 2014.01.06

JAVA 제네릭 컬렉션 실습

Programming/JAVA,JSP 2014. 1. 9. 16:32 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

1. 아이디 비밀번호 시스템 (Map)

ex)
아이디 : tansanc
비밀번호 : green
로그인 성공!!

아이디 : tansanc
비밀번호 : green1
비밀번호가 틀렸습니다.

아이디 : tansanc2
비밀번호 : green
존재하지 않는 아이디 입니다.

 

2. (Set) 쿵쿵따
제시어 : 기러기 //랜덤하게

기러기
기차표
표인봉
봉우리
이무기
기러기  // 땡!! 중복

 

3. 배열값을 10개 입력 받고
정렬하여 출력

 

4. 10000개 짜리 ArrayList,
 LinkedList 를 만들어서
 remove 속도 비교
 System.currentTimeMillis();

 

 

'Programming > JAVA,JSP' 카테고리의 다른 글

JAVA 쿵쿵따 게임 #2 중복 탐지  (0) 2014.01.09
JAVA 쿵쿵따 게임  (0) 2014.01.09
JAVA 객체지향 핵심 이론  (0) 2014.01.07
JAVA 행렬 곱셈 결과  (0) 2014.01.06
JAVA 배열 정렬 예제  (0) 2014.01.06

JAVA 객체지향 핵심 이론

Programming/JAVA,JSP 2014. 1. 7. 16:43 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

1. 왜 객체지향이 더 좋은지?
2. 객체와 클래스 뭐가 다른지?
3. 객체를 추상화 ex) 강아지
4. 객체지향의 캡슐화 설명
5. 객체지향의 캡슐화의 장점   왜 캡슐화를 쓰는지?
6. 객제지향의 상속 설명
7. 객체지향의 상속의 장점      왜 상속을 쓰는지?
8. 생성자 함수는 언제 불리는가?
9. 디폴트 생성자 함수는 언제 사용되는가?
10. 기초자료형과 참조자료형 의 차이점은?
11. 다중 상속이 안되는 이유? 다중 상속의 단점(CPP)

 

12. 인터페이스 장점
13. 추상클래스, 추상메소드 장점
14. 다형성 설명
15. 다형성 장점
16. 제네릭의 장점
17. 콜렉션은 무엇인가?

'Programming > JAVA,JSP' 카테고리의 다른 글

JAVA 쿵쿵따 게임  (0) 2014.01.09
JAVA 제네릭 컬렉션 실습  (1) 2014.01.09
JAVA 행렬 곱셈 결과  (0) 2014.01.06
JAVA 배열 정렬 예제  (0) 2014.01.06
JAVA 행렬 합곱 예제  (0) 2014.01.06

JAVA 행렬 곱셈 결과

Programming/JAVA,JSP 2014. 1. 6. 17:53 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

import java.util.Scanner;

 

public class ArrayTest4 {

   public static void main(String[] args) {

 

       int[][] matrix1 = { { 1, 2 }, { 3, 4 } };

       // [2][2]

       int[][] matrix2 = { { 3, 1 }, { 4, 2 } };

       int[][] matrix3 = matrixSum(matrix1, matrix2);

       int[][] matrix4 = matrixMul(matrix1, matrix2);

       // 행렬 합

 

       matrixPrint(matrix3);

       // 행렬 출력

   }

 

   private static int[][] matrixMul(int[][] matrix1, int[][] matrix2) {

       int[][] resultMatrix = new int[2][2];

 

       for (int j = 0; j < 2; j++) {

          for (int i = 0; i < 2; i++) {

            resultMatrix[j][i] = matrix1[j][0] * matrix2[0][i]

                    + matrix1[j][1] * matrix2[1][i];

          }

       }

 

       return resultMatrix;

   }

 

   private static void matrixPrint(int[][] matrix4) {

       for (int i = 0; i < 2; i++) {

          System.out.print("{");

          for (int j = 0; j < 2; j++) {

             System.out.print(" " + matrix4[i][j] + " ");

          }

          System.out.println("}");

       }

   }

 

   private static int[][] matrixSum(int[][] matrix1, int[][] matrix2) {

       int[][] resultMatrix = new int[2][2];

 

       for (int j = 0; j < 2; j++) {

          for (int i = 0; i < 2; i++) {

            resultMatrix[j][i] = matrix1[j][i] + matrix2[j][i];

          }

       }

 

       return resultMatrix;

   }

}

 

'Programming > JAVA,JSP' 카테고리의 다른 글

JAVA 제네릭 컬렉션 실습  (1) 2014.01.09
JAVA 객체지향 핵심 이론  (0) 2014.01.07
JAVA 배열 정렬 예제  (0) 2014.01.06
JAVA 행렬 합곱 예제  (0) 2014.01.06
Java Calendar  (0) 2013.12.31

JAVA 배열 정렬 예제

Programming/JAVA,JSP 2014. 1. 6. 17:46 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

import java.util.Scanner;

 

public class ArrayTest4 {

   public static void main(String[] args) {

 

       int[] array = { 70, 40, 150, 30};

      

       sortArray(array);

       for( int i = 0 ; i < array.length ; i++ )

       {

          System.out.println(array[i]);

       }

   }

 

   private static void sortArray(int[] array) {

       // TODO Auto-generated method stub

       int temp;

       // SWAP algo

       if( array[0] > array[1])

       {

          temp = array[0];

          array[0] = array[1];

          array[1] = temp;

       }

       if( array[1] > array[2])

       {

          temp = array[1];

          array[1] = array[2];

          array[2] = temp;

       }

       if( array[2] > array[3])

       {

          temp = array[2];

          array[2] = array[3];

          array[3] = temp;

       }

       // 1 Cycle

      

       if( array[0] > array[1])

       {

          temp = array[0];

          array[0] = array[1];

          array[1] = temp;

       }

       if( array[1] > array[2])

       {

          temp = array[1];

          array[1] = array[2];

          array[2] = temp;

       }

       // 2Cycle

       if( array[0] > array[1])

       {

          temp = array[0];

          array[0] = array[1];

          array[1] = temp;

       }

       // 3Cycle

   }

 

}

 

 

'Programming > JAVA,JSP' 카테고리의 다른 글

JAVA 객체지향 핵심 이론  (0) 2014.01.07
JAVA 행렬 곱셈 결과  (0) 2014.01.06
JAVA 행렬 합곱 예제  (0) 2014.01.06
Java Calendar  (0) 2013.12.31
JAVA Calendar #2  (0) 2013.12.31