繁体   English   中英

ActivityManager:警告:活动尚未开始,其当前任务已被带到最前面继续弹出?

[英]ActivityManager: Warning: Activity not started, its current task has been brought to the front keeps popping up?

我是Android开发工具世界的新手,我刚刚在笔记本电脑上下载了Eclipse和ADT插件。 我只是按照我在网上观看的视频教程制作了一个按钮,但在模拟器上无法使用,因此我尝试将android手机连接到笔记本电脑并下载了所需的驱动程序。 在android设备上,程序包本身会弹出,但是我做的按钮不会弹出。 讯息

ActivityManager:警告:活动尚未开始,其当前任务已被置于最前面

说完以下所有内容后,总是会在控制台上弹出:

Android Launch! 
[2014-07-24 08:22:11 - PLEASEBUTTON] adb is running normally. 
[2014-07-24 08:22:11 - PLEASEBUTTON] Performing com.example.pleasebutton.MainActivity activity launch 
[2014-07-24 08:22:13 - PLEASEBUTTON] Application already deployed. No need to reinstall. 
[2014-07-24 08:22:13 - PLEASEBUTTON] Starting activity com.example.pleasebutton.MainActivity on device 3934C3A970FE00EC 
[2014-07-24 08:22:13 - PLEASEBUTTON] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.pleasebutton/.MainActivity } 
[2014-07-24 08:22:14 - PLEASEBUTTON] ActivityManager: Warning: Activity not started, its current task has been brought to the front

我仍然不知道发生了什么,我真的想解决这个问题。

package com.example.pleasebutton;

import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBar;
import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.os.Build;
import android.app.Activity;
import android.view.View;
import android.widget.Toast;


public class MainActivity extends Activity implements View.OnClickListener{

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


 }
 public void onClick(View v){}   
 public void buttonBtn (View v) {
     Toast.makeText(this,"You just pressed a button",Toast.LENGTH_LONG).show();

 }
}

这是活动xml文件

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.pleasebutton.MainActivity"
tools:ignore="MergeRootFrame" />

这是片段xml文件

<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.pleasebutton.MainActivity$PlaceholderFragment" >

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/hello_world" />

<Button
    android:id="@+id/awesomebutton"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:onClick="buttonBtn"
    android:text="Cool Button" />

试试这个代码:

public class MainActivity extends Activity {

    private Button bAfficher;


    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        // Assign graphical button to attribute

        bAfficher = (Button) this.findViewById(R.id.awesomebutton);



        bAfficher.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {

                 Toast.makeText(this,"You just pressed a button",Toast.LENGTH_LONG).show();

 }
});
}
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM