Android资源 - 无法进入

时间:2017-06-13 21:33:57

标签: java android android-studio resources

我将我的应用程序重写为新项目,以使代码更整洁,并使用Android Studio中预定义的全屏活动。该应用程序工作得很好(至少超过现在崩溃的时间点)。该应用程序通过自定义CursorAdaper从SQLite数据库填充gridview,并且错误似乎在那里,更具体地说 - 它看起来像应该填充的布局的问题(固定尺寸的线性视图,2个孩子 - ImageView和TextView

从R.java中的第一行检查资源,并将此值分配给应该由游标充气的布局名称。知道怎么解决吗?

W/ResourceType: Failure getting entry for 0x7f040031 (t=3 e=49) (error -75)
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
              Process: com.madry.mtg, PID: 21183
              android.content.res.Resources$NotFoundException: Resource ID #0x7f040031
                  at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:198)
                  at android.content.res.Resources.loadXmlResourceParser(Resources.java:2114)
                  at android.content.res.Resources.getLayout(Resources.java:1115)
                  at android.view.LayoutInflater.inflate(LayoutInflater.java:424)
                  at com.madry.mtg.MyCursorAdapter.newView(MyCursorAdapter.java:33)
                  at android.widget.CursorAdapter.getView(CursorAdapter.java:285)
                  at android.widget.AbsListView.obtainView(AbsListView.java:2433)
                  at android.widget.GridView.onMeasure(GridView.java:1065)
                  at android.view.View.measure(View.java:19785)
                  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6120)
                  at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464)
                  at android.widget.LinearLayout.measureHorizontal(LinearLayout.java:1117)
                  at android.widget.LinearLayout.onMeasure(LinearLayout.java:642)
                  at android.view.View.measure(View.java:19785)
                  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6120)
                  at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
                  at android.view.View.measure(View.java:19785)
                  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6120)
                  at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
                  at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:139)
                  at android.view.View.measure(View.java:19785)
                  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6120)
                  at android.support.v7.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:393)
                  at android.view.View.measure(View.java:19785)
                  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6120)
                  at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
                  at android.view.View.measure(View.java:19785)
                  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6120)
                  at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464)
                  at android.widget.LinearLayout.measureVertical(LinearLayout.java:758)
                  at android.widget.LinearLayout.onMeasure(LinearLayout.java:640)
                  at android.view.View.measure(View.java:19785)
                  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6120)
                  at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
                  at com.android.internal.policy.DecorView.onMeasure(DecorView.java:690)
                  at android.view.View.measure(View.java:19785)
                  at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2275)
                  at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1362)
                  at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1611)
                  at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1250)
                  at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6311)
                  at android.view.Choreographer$CallbackRecord.run(Choreographer.java:871)
                  at android.view.Choreographer.doCallbacks(Choreographer.java:683)
                  at android.view.Choreographer.doFrame(Choreographer.java:619)
                  at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:857)
                  at android.os.Handler.handleCallback(Handler.java:751)
                  at android.os.Handler.dispatchMessage(Handler.java:95)
                  at android.os.Looper.loop(Looper.java:241)
                  at android.app.ActivityThread.main(ActivityThread.java:6217)
                  at java.lang.reflect.Method.invoke(Native Method)
                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)

MyCursorAdapter类

import android.content.Context;
import android.database.Cursor;
 import android.util.Log;
 import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CursorAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import static com.madry.mtg.MyDBHandler.COLUMN_COLOUR;
import static com.madry.mtg.MyDBHandler.COLUMN_POWER;
import static com.madry.mtg.MyDBHandler.COLUMN_TAP;
import static com.madry.mtg.MyDBHandler.COLUMN_TS;

public class MyCursorAdapter extends CursorAdapter{



private LayoutInflater cursorInflater;

public MyCursorAdapter(Context context, Cursor c, int flags) {
    super(context, c, flags);
    cursorInflater = (LayoutInflater) context.getSystemService(
            Context.LAYOUT_INFLATER_SERVICE);
}

@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
    return cursorInflater.inflate(R.layout.token, parent, false);
}

@Override
public void bindView(View view, Context context, Cursor cursor) {
    Log.d("adapter", "zaczelo wiazac");
    Symbol symbol = new Symbol();
    String sciezka = cursor.getString(cursor.getColumnIndexOrThrow(COLUMN_COLOUR));
    symbol.setPath(sciezka);

    int path = symbol.getPath();

    ImageView clr = (ImageView) view.findViewById(R.id.imageView);
    clr.setImageResource(path);

    int tap = cursor.getInt((cursor.getColumnIndexOrThrow(COLUMN_TAP)));
    if (tap == 0){
        view.setRotation(0);
    } else {
        view.setRotation(20);
    }


    TextView stats = (TextView) view.findViewById(R.id.textView2);
    String p = cursor.getString(cursor.getColumnIndexOrThrow(COLUMN_POWER))+
            "/" + cursor.getString(cursor.getColumnIndexOrThrow(COLUMN_TS));
    stats.setText(p);
   }

}

0 个答案:

没有答案