第二个活动不起作用 - Android开发

时间:2014-04-27 02:31:34

标签: android android-activity

好的,所以我已经克服了很多错误,只是因为我的应用程序崩溃了我试图访问我的第二个Activity。错误指向我的第二个活动的类,它位于布局类的内部。我试图在src中创建我的第二个活动类,但Android Studio似乎不想让我。有没有其他人遇到过这个问题,你有建议吗?谢谢。这是我的第二个活动的代码,以及我的AndroidManifest。

package com.example.friendlistcleaner.app;


import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;

public class facebookhandler extends ActionBarActivity
{


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

    // Get the message from the intent
    Intent intent = getIntent();
    String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);

    // Create the text view
    TextView textView = new TextView(this);
    textView.setTextSize(40);
    textView.setText(message);

    // Set the text view as the activity layout
    setContentView(textView);

}


@Override
public boolean onCreateOptionsMenu(Menu menu) {

    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.facebookhandler, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();
    if (id == R.id.action_settings) {
        return true;
    }
    return super.onOptionsItemSelected(item);
}

}

AndroidManifest

<?xml version="1.0" encoding="utf-8"?>
<!--
 * Copyright 2010-present Facebook.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
-->

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="com.facebook.android">
<application/>
<uses-sdk android:minSdkVersion="8" />
    <activity
     android:name="com.example.FacebookCleaner.FacebookHandler"
     android:label="message"
     android:parentActivityName="com.example.FacebookCleaner.MainActivity" >
     <meta-data
         android:name="android.support.PARENT_ACTIVITY"
         android:value="com.example.FacebookCleaner.MainActivity" />
    </activity>
</manifest>

堆栈跟踪

04-26 22:43:44.803  32315-32315/com.example.friendlistcleaner.app D/libEGL﹕ loaded         /system/lib/egl/libEGL_adreno200.so
04-26 22:43:44.803  32315-32315/com.example.friendlistcleaner.app D/libEGL﹕ loaded    /system/lib/egl/libGLESv1_CM_adreno200.so
04-26 22:43:44.823  32315-32315/com.example.friendlistcleaner.app D/libEGL﹕ loaded /system/lib/egl/libGLESv2_adreno200.so
04-26 22:43:44.873  32315-32315/com.example.friendlistcleaner.app I/Adreno200-EGL﹕  <qeglDrvAPI_eglInitialize:265>: EGL 1.4 QUALCOMM build:    HAREESHG_Nondeterministic_AU+PATCH[ES]_msm8960_JB_1.9.6_MR2_CL3219408_release_ENGG   (CL3219408)
    Build Date: 09/28/13 Sat
    Local Branch: hhh
    Remote Branch: quic/jb_1.9.6_1
    Local Patches: 8d50ec23e42ef52b570aa6ff1650afac0b503d78 CL3219408: Fix in the   Glreadpixels for negative offsets and larger dimensions.
    801859126f6ca69482b39a34ca61447e3f7cded8 rb: fix panel settings to clear     undrawn/undefined buffers
    Reconstruct Branch: LOCAL_PATCH[ES]
04-26 22:43:45.093  32315-32315/com.example.friendlistcleaner.app D/OpenGLRenderer﹕     Enabling debug mode 0
04-26 22:43:45.163  32315-32315/com.example.friendlistcleaner.app D/OpenGLRenderer﹕ GL    error from OpenGLRenderer: 0x502
04-26 22:43:45.163  32315-32315/com.example.friendlistcleaner.app E/OpenGLRenderer﹕   GL_INVALID_OPERATION

1 个答案:

答案 0 :(得分:0)

我的猜测是你不应该在布局中创建Activity。 如果您在src文件夹下使用Android Studio,请右键单击包名称。 然后选择&#34; New&#34; - &GT; &#34;活动&#34;等等 http://i57.tinypic.com/nezs5g.png