android这个错误怎么改啊?

问题描述

android这个错误怎么改啊?

两部分代码分开写可以,放在一起写不知道哪里错了
.


import java.util.ArrayList;
import java.util.List;

import android.app.ActionBar;
import android.app.Activity;
import android.content.res.Configuration;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.app.ActionBarDrawerToggle;
import android.support.v4.widget.DrawerLayout;
import android.support.v4.widget.DrawerLayout.DrawerListener;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v4.widget.SwipeRefreshLayout.OnRefreshListener;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

public class MainActivity extends Activity implements OnItemClickListener,
        DrawerListener {
    private DrawerLayout drawerLayout;
    private ListView lv_drawer;
    private ArrayAdapter<String> adapter_drawer;
    private ArrayList<String> list_drawer;
    private String string_drawer;
    private ActionBarDrawerToggle toggle;

    private ListView lv_swiperefresh;
    private SwipeRefreshLayout swipeRefreshLayout;
    private ArrayAdapter<String> adapter_swipe;
    private ArrayList<String> list_swipe;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        drawerLayout = (DrawerLayout) findViewById(R.id.drawer);
        lv_drawer = (ListView) findViewById(R.id.list_drawer);
        list_drawer = new ArrayList<String>();
        for (int i = 0; i <= 5; i++) {
            list_drawer.add("天香-天心" + i);
        }
        adapter_drawer = new ArrayAdapter<String>(this,
                android.R.layout.simple_list_item_1, list_drawer);
        lv_drawer.setAdapter(adapter_drawer);
        lv_drawer.setOnItemClickListener(this);

        ActionBar bar = getActionBar();
        bar.setDisplayHomeAsUpEnabled(true);
        bar.setHomeButtonEnabled(true);
        string_drawer = (String) bar.getTitle();
        toggle = new ActionBarDrawerToggle(this, drawerLayout,
                android.R.drawable.ic_media_play, 0, 0);
        drawerLayout.setDrawerListener(this);

        lv_swiperefresh = (ListView) findViewById(R.id.lv_swipe);
        swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swiperefreshlayout);
        list_swipe = new ArrayList<String>();
        for (int i = 0; i <= 3; i++) {
            list_swipe.add("项目" + i);
        }
        adapter_swipe = new ArrayAdapter<String>(this, R.layout.item,
                R.id.lv_swipe, list_swipe);
        lv_swiperefresh.setAdapter(adapter_swipe);

        swipeRefreshLayout.setOnRefreshListener(new OnRefreshListener() {

            @Override
            public void onRefresh() {
                new updata().execute();

            }
        });
    }

    private class updata extends AsyncTask<Void, Void, List<String>> {

        @Override
        protected List<String> doInBackground(Void... params) {
            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            List<String> newData = new ArrayList<String>();
            newData.add("新数据1");
            newData.add("新数据2");
            newData.add("新数据3");
            return newData;
        }

        @Override
        protected void onPostExecute(List<String> result) {
            adapter_swipe.addAll(result);
            swipeRefreshLayout.setRefreshing(false);
        }

    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        int id = item.getItemId();
        if (toggle.onOptionsItemSelected(item)) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

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

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

    @Override
    public void onDrawerClosed(View arg0) {
        getActionBar().setTitle(string_drawer);
    }

    @Override
    public void onDrawerOpened(View arg0) {

        getActionBar().setTitle("success");
    }

    @Override
    public void onDrawerSlide(View arg0, float arg1) {

    }

    @Override
    public void onDrawerStateChanged(int arg0) {

    }

    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position,
            long id) {
        Toast.makeText(this, lv_drawer.getItemAtPosition(position).toString(),
                Toast.LENGTH_SHORT).show();
        drawerLayout.closeDrawer(lv_drawer);
    }
}

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

    <android.support.v4.widget.DrawerLayout
        android:id="@+id/drawer"
        android:layout_height="match_parent"
        android:layout_width="match_parent">
        <FrameLayout
            android:id="@+id/frame_drawer"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            >
        </FrameLayout>
        <ListView
            android:id="@+id/list_drawer"
            android:layout_width="240dp"
            android:layout_height="match_parent"
            android:layout_gravity="start"
            android:choiceMode="singleChoice"
            android:divider="@android:color/transparent"
            android:dividerHeight="0dp"
            android:background="#ffffcc"
            ></ListView>
    </android.support.v4.widget.DrawerLayout>
    <android.support.v4.widget.SwipeRefreshLayout
        android:id="@+id/swiperefreshlayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        >
        <ListView
            android:id="@+id/lv_swipe"
            android:layout_width="match_parent"
            android:layout_height="match_parent" >
        </ListView>
    </android.support.v4.widget.SwipeRefreshLayout>
</RelativeLayout>

 <?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" >
    <TextView
        android:id="@+id/tv"
        android:layout_width="match_parent"
        android:layout_height="40dip"
        android:textColor="#000"
        android:gravity="center_vertical"
        android:textSize="18sp" /> 

</LinearLayout>

【错误报告】
.

 10-03 03:18:42.596: E/memtrack(1969): Couldn't load memtrack module (No such file or directory)
10-03 03:18:42.606: E/android.os.Debug(1969): failed to load memtrack module: -2
10-03 03:18:42.936: E/memtrack(1979): Couldn't load memtrack module (No such file or directory)
10-03 03:18:42.936: E/android.os.Debug(1979): failed to load memtrack module: -2
10-03 03:18:42.976: E/gralloc_goldfish(939): gralloc_alloc: Mismatched usage flags: 246 x 410, usage 333
10-03 03:18:42.976: E/(939): GraphicBufferAlloc::createGraphicBuffer(w=246, h=410) failed (Invalid argument), handle=0x0
10-03 03:18:42.976: E/BufferQueue(1278): [ScreenshotClient] dequeueBuffer: SurfaceComposer::createGraphicBuffer failed
10-03 03:18:43.136: E/AndroidRuntime(1991): FATAL EXCEPTION: main
10-03 03:18:43.136: E/AndroidRuntime(1991): Process: com.example.refresh_drawer_demo, PID: 1991
10-03 03:18:43.136: E/AndroidRuntime(1991): android.util.SuperNotCalledException: Activity {com.example.refresh_drawer_demo/com.example.refresh_drawer_demo.MainActivity} did not call through to super.onPostCreate()
10-03 03:18:43.136: E/AndroidRuntime(1991):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
10-03 03:18:43.136: E/AndroidRuntime(1991):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
10-03 03:18:43.136: E/AndroidRuntime(1991):     at android.app.ActivityThread.access$800(ActivityThread.java:135)
10-03 03:18:43.136: E/AndroidRuntime(1991):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
10-03 03:18:43.136: E/AndroidRuntime(1991):     at android.os.Handler.dispatchMessage(Handler.java:102)
10-03 03:18:43.136: E/AndroidRuntime(1991):     at android.os.Looper.loop(Looper.java:136)
10-03 03:18:43.136: E/AndroidRuntime(1991):     at android.app.ActivityThread.main(ActivityThread.java:5017)
10-03 03:18:43.136: E/AndroidRuntime(1991):     at java.lang.reflect.Method.invokeNative(Native Method)
10-03 03:18:43.136: E/AndroidRuntime(1991):     at java.lang.reflect.Method.invoke(Method.java:515)
10-03 03:18:43.136: E/AndroidRuntime(1991):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
10-03 03:18:43.136: E/AndroidRuntime(1991):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
10-03 03:18:43.136: E/AndroidRuntime(1991):     at dalvik.system.NativeStart.main(Native Method)
10-03 03:18:43.366: E/gralloc_goldfish(939): gralloc_alloc: Mismatched usage flags: 246 x 410, usage 333
10-03 03:18:43.366: E/(939): GraphicBufferAlloc::createGraphicBuffer(w=246, h=410) failed (Invalid argument), handle=0x0
10-03 03:18:43.366: E/BufferQueue(1278): [ScreenshotClient] dequeueBuffer: SurfaceComposer::createGraphicBuffer failed
10-03 03:18:53.006: E/WindowManager(1278): Starting window AppWindowToken{b34da468 token=Token{b3681700 ActivityRecord{b39889b0 u0 com.example.refresh_drawer_demo/.MainActivity t5}}} timed out

解决方案

说明白点,就是**public class MainActivity extends Activity**和 private class updata extends AsyncTask
这两个类不能同时出现在一个类中,建议你最好分开写。

解决方案二:

Android 编译源码 错误

解决方案三:

把错误提示贴出来看看

解决方案四:

这个问题的直接原因是由于你忘记了 JAVA的一个class不能同时extends两个类,这是属于语法错误,建议你再看下相关的书籍就能搞定。

解决方案五:

提示信息不是说了你的onPostCreate()方法里没有调用父类方法吗?

解决方案六:

 android.util.SuperNotCalledException: Activity {com.example.refresh_drawer_demo/com.example.refresh_drawer_demo.MainActivity} did not call through to super.onPostCreate()

这段看明白了吗?

解决方案七:

提示信息不是说了你的onPostCreate()方法里没有调用父类方法吗?

时间: 2025-01-30 17:41:25

android这个错误怎么改啊?的相关文章

myproject-AndroidStudio中com.android.support错误如何解决

问题描述 AndroidStudio中com.android.support错误如何解决 今天在AndroidStudio中创建项目老是出现 ** E:AndroidStudioProjectsHelloStudiomyprojectbuildintermediatesexploded-aarcom.android.supportappcompat-v721.0.3resdrawable-mdpiabc_ab_share_pack_holo_dark.9.png: libpng warning:

语句-下面的错误怎么改啊,请大家教教我

问题描述 下面的错误怎么改啊,请大家教教我 void SelectMin(MyHuffmanNode MYN[ML]){ int min1min2; min1=min2=0; int i; for(i=0;i<2*ML-1;i++) { if(MYN[i].weight<MYN[min1].weight && MYN[i].father=-1) min1=i; } min2=min1+1; for(i=0;i<2*ML-1;i++) { if(MYN[i].weight&

android sdk 错误,不知道怎么回事,菜鸟求救!!!

问题描述 android sdk 错误,不知道怎么回事,菜鸟求救!!! 解决方案 在preferences-android,里面配置一下你自己的sdk路径试试. 解决方案二: 先卸载重新安装一下sdk排除一下错误不行再从路径和环境变量找问题 解决方案三: 重新配置SDK的路径.

c++-求大神!关于IO 输出运算符重载 这是什么错误 怎么改?

问题描述 求大神!关于IO 输出运算符重载 这是什么错误 怎么改? #include"iostream" #include"fstream" #include"string" using namespace std; class coStu { protected: string name,num; double score; public: coStu(string na,string nu,double s): name(na),num(nu

android EACCES 错误

问题描述 android EACCES 错误 java.io.FileNotFoundException: /mnt/sdcard/ttt.tt: open failed: EACCES (Permission denied)android小白,出错如上,已经申请了 2个权限,写文件到SD卡报这个错误,请问大牛们这是怎么回事? 部分代码:File file = new File(Environment.getExternalStorageDirectory() filename);Log.i("

编码-下面的错误怎么改啊,请大家帮帮我,我刚开始写,写不好啊。耐心看一下,谢谢!!

问题描述 下面的错误怎么改啊,请大家帮帮我,我刚开始写,写不好啊.耐心看一下,谢谢!! #include <iostream> #include <string> #define MAX 100 using namespace std; class HTNode { public: int weight; string data; int f; HTNode* father; HTNode* lchild; HTNode* rchild; string code; HTNode()

初学者-各位大神,能不能帮看一下问题是在哪,一直提示错误,改了好多遍都没还对

问题描述 各位大神,能不能帮看一下问题是在哪,一直提示错误,改了好多遍都没还对 package jsp; public class Circle { double side; double areaperimeter; public void setCircle(double r){ side=r; } public double getCircle(){ return side; } public double getArea(){ area=Math.sqrt(3.14*side*side)

c++课程设计中五子棋程序中这个错误怎么改?

问题描述 c++课程设计中五子棋程序中这个错误怎么改? 大神们求教这个图片中的错误怎么改-------------- 解决方案 找不到你引用 的graphi.h这个头文件.你把这个文件找到然后放到相应目录下就好了. 解决方案二: 找不到你引用 的graphi.h这个头文件.你把这个文件找到然后放到相应目录下就好了. 解决方案三: http://www.bcwhy.com/thread-10364-1-1.html

jsp-tomcat提示404错误怎么改

问题描述 tomcat提示404错误怎么改 提示这个错误,如果打开jsp就提示404 应该怎么改? 解决方案 先看myeclipse 配置都对不对.先建个jsp 页面 看看能否跑起来,.能跑说明 myeclipse 配置没问题.最容易错的就是.你的struts.xml中的<?xml version=""1.0"" encoding=""UTF-8"" ?><!DOCTYPE struts PUBLIC-//A