안드로이드
- 안드로이드 :: 뷰 페이저 2017.06.26
- 안드로이드 :: API 에러 2017.06.26
- 안드로이드 :: 타이틀바와 상태바 색상 바꾸기 2017.06.25
- 안드로이드 오류 :: Application Installation Failed 2017.06.25
- 안드로이드 상태 바 / 타이틀 바 없애기 2017.06.19
안드로이드 :: 뷰 페이저
MainActivity.java
public class MainActivity extends ActionBarActivity{
Button btn[] = new Button[3];
ViewPager viewPager = null;
int p=0; //페이지번호
int v=1; //화면 전환 뱡향
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
viewPager = (ViewPager)findViewById(R.id.viewPager);
MyViewPagerAdapter adapter = new MyViewPagerAdapter(getSupportFragmentManager());
viewPager.setAdapter(adapter);
}
}
activity_main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<!--
<Button
android:id="@+id/btn_a"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="A"
style="@style/Widget.AppCompat.ActionButton"/>
<Button
android:id="@+id/btn_b"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="B"
style="@style/Widget.AppCompat.ActionButton"/>
<Button
android:id="@+id/btn_c"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="C"
style="@style/Widget.AppCompat.ActionButton"/>
-->
</LinearLayout>
<android.support.v4.view.ViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
fragmentA.java
public class FragmentA extends Fragment{
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_a, container, false);
}
}
fragment_a.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#5DA4BE">
</LinearLayout>
마찬가지로 fragmentB.java fragmentC.java fragment_b.xml fragment_c.xml 생성
'Android' 카테고리의 다른 글
안드로이드 :: 버튼 클릭 이벤트 처리 코드 처리 (0) | 2017.06.26 |
---|---|
안드로이드 :: API 에러 (0) | 2017.06.26 |
안드로이드 :: 레이아웃 xml 동적 변경 (0) | 2017.06.26 |
안드로이드 :: 인트로 화면 제작 (0) | 2017.06.25 |
안드로이드 :: 타이틀바와 상태바 색상 바꾸기 (0) | 2017.06.25 |
안드로이드 :: API 에러
위와같이 Call requires API level 16 (currentmin is 14): android.view.View#setBackground more
어쩌구 농락을 한다.
이럴땐 gradle 을 손보자.
들어가서
defaultConfig {
applicationId "com.fractalwrench.androidbootstrap.sample"
minSdkVersion Integer.parseInt(MIN_SDK_INT)
targetSdkVersion Integer.parseInt(TARGET_SDK_INT)
versionCode = Integer.parseInt(VERSION_CODE)
versionName = VERSION_NAME
}
변경해주자
defaultConfig {
applicationId "com.fractalwrench.androidbootstrap.sample"
minSdkVersion 16
targetSdkVersion Integer.parseInt(TARGET_SDK_INT)
versionCode = Integer.parseInt(VERSION_CODE)
versionName = VERSION_NAME
}
SDK 버전쪽을 변경해주면 끝
'Android' 카테고리의 다른 글
안드로이드 :: 뷰 페이저 (0) | 2017.06.26 |
---|---|
안드로이드 :: 버튼 클릭 이벤트 처리 코드 처리 (0) | 2017.06.26 |
안드로이드 :: 레이아웃 xml 동적 변경 (0) | 2017.06.26 |
안드로이드 :: 인트로 화면 제작 (0) | 2017.06.25 |
안드로이드 :: 타이틀바와 상태바 색상 바꾸기 (0) | 2017.06.25 |
안드로이드 :: 타이틀바와 상태바 색상 바꾸기
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimaryDark">#A1CDE1</item>
<item name="colorPrimary">#5DA4BE</item>
</style>
Styles.xml 에 위의 코드 추가
16진수 색상값만 원하는 값으로 변경해주면 됨
colorPrimaryDark : 상태바 ( 최상단 시간이랑 LTE, 와이파이 보여주는 바 )
colorPrimary : 타이틀바 ( 앱 이름 나오는 바 )
결과
코드 추가 전 코드 추가 후
'Android' 카테고리의 다른 글
안드로이드 :: API 에러 (0) | 2017.06.26 |
---|---|
안드로이드 :: 레이아웃 xml 동적 변경 (0) | 2017.06.26 |
안드로이드 :: 인트로 화면 제작 (0) | 2017.06.25 |
안드로이드 오류 :: Application Installation Failed (0) | 2017.06.25 |
안드로이드 상태 바 / 타이틀 바 없애기 (0) | 2017.06.19 |
안드로이드 오류 :: Application Installation Failed
오류 내용
Application Installation Failed
Installation failed with message Failed to finalize session : INSTALL_FAILED_INVALID_APK: Split lib_slice_7_apk was defined multiple times. It is possible that this issue is resolved by uninstalling an existing version of the apk if it is present, an existing version of the apk if it is present, and then re-installing.
WARNING: Uninstalling will remove the application data!
Do you want to uninstall the existing application?
----------------------------------------------------------------------------------------------------------------------------------
해결 방법
1. 상단에 Build 메뉴 - Clean Project 클릭
2. 상단에 Build 메뉴 - Rebuild Project 클릭
'Android' 카테고리의 다른 글
안드로이드 :: API 에러 (0) | 2017.06.26 |
---|---|
안드로이드 :: 레이아웃 xml 동적 변경 (0) | 2017.06.26 |
안드로이드 :: 인트로 화면 제작 (0) | 2017.06.25 |
안드로이드 :: 타이틀바와 상태바 색상 바꾸기 (0) | 2017.06.25 |
안드로이드 상태 바 / 타이틀 바 없애기 (0) | 2017.06.19 |
안드로이드 상태 바 / 타이틀 바 없애기
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
}
1. 위와 같이 MainActivity 자바 파일에 getWindow().setFlags( ... ); 을 추가하면 상태바를 없앨 수 있다.
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<!-- No Title Bar-->
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
</resources>
2. 위와 같이 values 폴더 내에 있는 styles.xml파일에 No Title Bar 부분의 코드를 추가해주면 타이틀 바를 없앨 수 있다.
'Android' 카테고리의 다른 글
안드로이드 :: API 에러 (0) | 2017.06.26 |
---|---|
안드로이드 :: 레이아웃 xml 동적 변경 (0) | 2017.06.26 |
안드로이드 :: 인트로 화면 제작 (0) | 2017.06.25 |
안드로이드 :: 타이틀바와 상태바 색상 바꾸기 (0) | 2017.06.25 |
안드로이드 오류 :: Application Installation Failed (0) | 2017.06.25 |