Android 안드로이드2014. 12. 2. 17:12















xml로 layout를 만들필요 없는 대화상자

xml로 레이아웃을 만들필요 없는 대화상자


AlertDialog.Builder newDialog = new AlertDialog.Builder(this);

newDialog.setTitle("New drawing");

newDialog.setMessage("Start new Live Memo (you will lose the current memo)?");

newDialog.setPositiveButton("Yes", new DialogInterface.OnClickListener(){

public void onClick(DialogInterface dialog, int which){

doSomething();

dialog.dismiss();

}

});

newDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener(){

public void onClick(DialogInterface dialog, int which){

doCancel();

dialog.cancel();

}

});

newDialog.show();

eturn true;






-------------------------------

레이아웃을 만들어 커스터마이징이 가능한  커스텀 대화상자


            final Dialog dialog = new Dialog(YourActivity.this);

            dialog.setContentView(R.layout.dialog_your);

            dialog.setTitle("Select a item: ");

            dialog.show();

             

            Button bttn1 = (Button) dialog.findViewById(R.id.bttn_1);

            bttn1.setOnClickListener(new OnClickListener() {

                @Override

                public void onClick(View v) {

                  doSomething();

                    dialog.dismiss();

                }

            });

            ImageButton bttn2 = (ImageButton) dialog.findViewById(R.id.bttn_2);

            bttn2.setOnClickListener(new OnClickListener() {

                @Override

                public void onClick(View v) {

                 doCancel();

                    dialog.dismiss();

                }

            });



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

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

    android:layout_width="wrap_content"

    android:layout_height="wrap_content"

    android:gravity="center"

    android:orientation="vertical" >

    

<TextView

  android:id="@+id/message"

  android:text="Dialog .... ?"

  android:layout_width="wrap_content"

  android:layout_height="wrap_content" />


<LinearLayout

   android:layout_width="wrap_content"

   android:layout_height="wrap_content"

   android:layout_weight="1"

   android:orientation="horizontal" >


<Button

 android:id="@+id/bttn_1"

 android:layout_width="wrap_content"

 android:layout_height="wrap_content"

 android:layout_centerHorizontal="true"

 android:text="OK" />

<ImageButton 

 android:id="@+id/bttn_2"

 android:layout_width="wrap_content"

 android:layout_height="wrap_content"

 android:layout_centerHorizontal="true"

 android:text="Cancel" />

</LinearLayout>

</LinearLayout>










Posted by 코드버무려
Android 안드로이드2014. 11. 30. 01:19

액션바 적용 유무에 따른 styles.xml  파일 내용

Actionbar를 API 11이상, API 7 이상으로 했을 때에 따른 styles.xml파일 내용 변경 점.


2일간 지우고 깔고 임포트하고 수차례 반복을 했다.


이클립스와 ADT 그리고 업데이트도 새로 받아서 설치했다.

기본 애플리케이션과 액티비티에 적용된 기본 테마는 Holo.Light.DarkActionBar이다.

이 테마는 안드로이드 프로젝트를 만들 때 기본 값으로 선택되는 theme이다.




[values 폴더] 

API 11+


<style name="AppBaseTheme" parent="android:Theme.Light">

<style name="AppTheme" parent="AppBaseTheme">


API 7+

<style name="AppBaseTheme" parent="Theme.AppCompat.Light">

<style name="AppTheme" parent="AppBaseTheme">


------------


[values-v11 폴더]

API 11+

<style name="AppBaseTheme" parent="android:Theme.Holo.Light">


API 7+

<style name="AppBaseTheme" parent="Theme.AppCompat.Light">


-----------------


[values-v14 폴더]

API 11+

<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">


API 7+

<style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">



------------------


<resources>

    <!-- the theme applied to the application or activity -->

    <style name="CustomActionBarTheme"

           parent="@android:style/Theme.AppCompat">

        <item name="android:windowActionBarOverlay">true</item>


        <!-- Support library compatibility -->

        <item name="windowActionBarOverlay">true</item>

    </style>

</resources>



똑같은 에러를 만났다.

android:windowActionBarOverlay requires API level 11 (current min is 7)




아래 두 줄을 추가하면 해결된다.

<resources xmlns:tools="http://schemas.android.com/tools" xmlns:android="http://schemas.android.com/apk/res/android">

<item tools:targetApi="11" name="android:windowActionBarOverlay">true</item>



다른 방법으로는

<resources xmlns:tools="http://schemas.android.com/tools" xmlns:android="http://schemas.android.com/apk/res/android">

<item name="android:windowActionBarOverlay" tools:ignore="NewApi">true</item>

와 같이 작성하면 되겠다



styles.xml에서 부모를 접두어 "android:"를 빼고 아래와 같이 둔다

parent="@style/Theme.AppCompat"



 그리고 Androidmenifest.xml에서

android:minSdkVersion="7"


마지막으로

    <application

        android:allowBackup="true"

        android:icon="@drawable/ic_launcher"

        android:label="@string/app_name"

        android:theme="@style/AppTheme" >


.........

</application>

으로 해서 AppTheme를 불러주었으나 여전히도 이해할 수 없는 오류가 니오고 있다.




Posted by 코드버무려
Android 안드로이드2014. 11. 29. 20:24









Failed to create the java virtual machine


기존에 사용하던 이클립스에 간혹 오류가 나와 새롭게 이클립스를 받았다.

잔잔한 것부터 시작해서 avd 에물레이터를 생성하면 최신버전 롤리팝으로 만들어지거나 생성조차 안되는 문제를 겪고 있다.

Eclipse IDE with built-in ADT (Android Developer Tools) 압축을 이클립스 ADT를 설치하고자 하는 폴더에 풀었다.

이클립스를 실행하려고 하니 "Failed to create the java virtual machine"와 같은 에러가 나왔다.

이클립스가 설치된 폴더에서 eclipse.ini를 메모장에서 열어보자



-startup

plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar

--launcher.library

plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.200.v20120913-144807

-product

com.android.ide.eclipse.adt.package.adtproduct

-showsplash

org.eclipse.platform

--launcher.XXMaxPermSize

256m

--launcher.defaultAction

openFile

-vmargs

-Dosgi.requiredJavaVersion=1.6

-XX:MaxPermSize=256m

-Xms512m

-Xmx1024m

위 상자 박스와 같은 내용을 볼 수 있다.


-vm

C:\Program Files\Java\jdk1.7.0_65\bin\javaw.exe

 를 추가해준다. 아래 상자 박스와 같이 똑같은 위치에 위 코드를 넣는다.

(단 자바가 설치된 경로는 사용자마다 다르니 각자 설치 위치를 확인해서 설치주소를 복사해넣자.)



-startup

plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar

--launcher.library

plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.200.v20120913-144807

-product

com.android.ide.eclipse.adt.package.adtproduct

-showsplash

org.eclipse.platform

--launcher.XXMaxPermSize

256m

--launcher.defaultAction

openFile

-vm

C:\Program Files\Java\jdk1.7.0_65\bin\javaw.exe

-vmargs

-Dosgi.requiredJavaVersion=1.6

-XX:MaxPermSize=256m

-Xms512m

-Xmx1024m




Posted by 코드버무려
Android 안드로이드2014. 11. 28. 20:29


















앱에 proguard를 적용해서 export중에 아래와 같은 오류를 만나고 더는 진행안되었다. 


Proguard returned with error code 1. See console


AndroidManifest.xml에서 

android:minSdkVersion="3"을 android:minSdkVersion="7"로 바꿨더니 말끔히 해결되었다.

안드로이드 이클레어인 Android 2.0과 안드로이드 2.1 API7 레벨 하위 버전은 프로가드 적용이 앞으로 쉽지 않을 듯 하다 

Posted by 코드버무려
Android 안드로이드2014. 11. 25. 11:10

AVD에서 먼저 구글 광고가 나오지 않았다.

그리고 진짜 스마트폰에서도 똑같은 버젼의 앱을 올렸더니 구글 광고를 볼 수 없었다.


Posted by 코드버무려