게시판 즐겨찾기
편집
드래그 앤 드롭으로
즐겨찾기 아이콘 위치 수정이 가능합니다.
안드로이드 actionbaractiviy (?) 에러봐주세요 ..!
게시물ID : programmer_10787짧은주소 복사하기
작성자 : 멘붕과학생
추천 : 0
조회수 : 3629회
댓글수 : 13개
등록시간 : 2015/06/03 22:05:50
옵션
  • 본인삭제금지
-- 에러 --

06-03 12:46:02.266  24686-24686/com.example.cu.drawer E/AndroidRuntime﹕ FATAL EXCEPTION: main
    java.lang.ClassCastException: android.support.v7.internal.widget.ActionBarOverlayLayout$LayoutParams cannot be cast to android.widget.FrameLayout$LayoutParams
            at com.android.internal.widget.ActionBarOverlayLayout.applyInsets(ActionBarOverlayLayout.java:131)
            at com.android.internal.widget.ActionBarOverlayLayout.fitSystemWindows(ActionBarOverlayLayout.java:169)
            at android.view.ViewGroup.fitSystemWindows(ViewGroup.java:5395)
            at com.android.internal.policy.impl.PhoneWindow$DecorView.fitSystemWindows(PhoneWindow.java:2637)
            at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1328)
            at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1120)
            at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4604)
            at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
            at android.view.Choreographer.doCallbacks(Choreographer.java:555)
            at android.view.Choreographer.doFrame(Choreographer.java:525)
            at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
            at android.os.Handler.handleCallback(Handler.java:615)
            at android.os.Handler.dispatchMessage(Handler.java:92)
            at android.os.Looper.loop(Looper.java:137)
            at android.app.ActivityThread.main(ActivityThread.java:4921)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:511)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
            at dalvik.system.NativeStart.main(Native Method)

-- 여기까지 에러 --

네비게이션 드로어를 통해 fragment를 보여주는 소스가 있기에 그걸 따라서 작성하는 도중에
 에러가 떠서 막혓네요 ..

영어가 조금많이 짧아서 구글링 하다가 어찌저찌 여기까지 왓는데 모르겠어요 ...

api는 16 버전이고 .. sdk 에서 support는 받았습니다 . 현재 adt를 사용하다가 sdk 설치중 에러가 떠서
안드로이드 스튜디오로 작성하고 있습ㄴ디ㅏ ..

혹시 몰라서 

----manifest -- 
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.cu.drawer">
    <uses-sdk android:minSdkVersion="11" android:targetSdkVersion="18" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name">
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>
-- manifest --


-- style --

<resources>

    <!-- Base application theme. -->
    <style name="AppBaseTheme" parent="@android:style/Theme.Holo.Light">
        <!-- Customize your theme here. -->
    </style>
    <style name="AppTheme" parent="AppBaseTheme">

        <item name="android:windowNoTitle">false</item>
        <item name="android:windowActionBar">true</item>
        <!-- All customizations that are NOT specific to a particular API-level can go here. -->

    </style>
</resources>
--style--

-- activity--

package com.example.cu.drawer;

import android.app.Activity;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.content.res.Configuration;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.app.ActionBarDrawerToggle;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.FrameLayout;
import android.widget.ListView;

public class MainActivity extends ActionBarActivity {
private String[] menuItem = { "img", "text" };
private ListView list;
ArrayAdapter<String> adtDrawerList;

FrameLayout layout;
private DrawerLayout drawer;
private ActionBarDrawerToggle toggle;

TextFragment fragtext;
ImageFragment fragimage;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
fragtext = TextFragment.newInstance();
fragimage = new ImageFragment().newInstance();

getSupportFragmentManager().beginTransaction().replace(R.id.fl_activity_main_container, fragtext).commit();
// �����׸�Ʈ
list = (ListView) findViewById(R.id.lv_activity_main_nav_list);
// ����Ʈ�� ���̵� �޾ƿ�
layout = (FrameLayout) findViewById(R.id.fl_activity_main_container);
// ���̾ƿ� ���̵� �޾ƿ�
list.setAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, menuItem));
list.setOnItemClickListener(new DrawerItemClick());
// DrawerItemClick ���� Ŭ������ �ۼ��Ͽ� �޾ƿò���

drawer = (DrawerLayout) findViewById(R.id.dl_activity_main_drawer);
toggle = new ActionBarDrawerToggle(this, drawer, R.drawable.ic_drawer,
R.drawable.ic_action_back, R.drawable.ic_action_back) {
@Override
public void onDrawerClosed(View drawerView) {
super.onDrawerClosed(drawerView);
}

@Override
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
}
};
drawer.setDrawerListener(toggle);
getActionBar().setDisplayHomeAsUpEnabled(true);
}

protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
toggle.syncState();
}

@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
toggle.onConfigurationChanged(newConfig);
}

// �����ֱ� �޼ҵ�
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (toggle.onOptionsItemSelected(item)) {
return true;
}
return super.onOptionsItemSelected(item);

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {

getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}

private class DrawerItemClick implements ListView.OnItemClickListener {

@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {


switch (position) {
case 0:
getSupportFragmentManager().beginTransaction().replace(R.id.fl_activity_main_container, fragtext).commit();
break;
case 1:
getSupportFragmentManager().beginTransaction().replace(R.id.fl_activity_main_container, fragimage).commit();
break;

default:
break;
}
drawer.closeDrawer(list);


}

}
}

-- activity --

넴 ... 알려주시면 감사합니다 .. ㅠㅠㅠ 
출처 오늘 하루 .. 뭐한거지
전체 추천리스트 보기
새로운 댓글이 없습니다.
새로운 댓글 확인하기
글쓰기
◀뒤로가기
PC버전
맨위로▲
공지 운영 자료창고 청소년보호