0

我已经制作了所有按钮和所有链接都可以正常工作,但我遇到的问题是我必须从顶部按钮开始并选择它,然后才能继续使用后续按钮才能使每个按钮正常工作。换句话说,在我按顺序选择每个按钮之前,没有一个按钮起作用。我确定我在这里遗漏了一些简单的东西,只是对我在这里所做的事情一无所知。任何帮助表示赞赏,谢谢!

     package rainbow.cheetah.go.sms;

import android.app.Activity;
import android.os.Bundle;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class RainbowCheetahGOSMSActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);


        Button btn = (Button) findViewById(R.id.More);
        btn.setOnClickListener(new OnClickListener() {
                public void onClick(View v) {
                        Intent myWebLink = new Intent(android.content.Intent.ACTION_VIEW);
                        myWebLink.setData(Uri.parse("https://play.google.com/store/search?q=stealthychief&c=apps"));
                        startActivity(myWebLink); 



                       Button btn = (Button) findViewById(R.id.match);
                        btn.setOnClickListener(new OnClickListener() {
                                public void onClick(View v) {
                                        Intent myWebLink = new Intent(android.content.Intent.ACTION_VIEW);
                                        myWebLink.setData(Uri.parse("https://play.google.com/store/search?q=rainbow+cheetah+stealthychief&c=apps"));
                                        startActivity(myWebLink);  


                        Button btn = (Button) findViewById(R.id.rate);
                        btn.setOnClickListener(new OnClickListener() {
                                public void onClick(View v) {
                                        Intent myWebLink = new Intent(android.content.Intent.ACTION_VIEW);
                                        myWebLink.setData(Uri.parse("https://play.google.com/store/apps/details?id=rainbow.cheetah.go.sms&feature=search_result#?t=W251bGwsMSwxLDEsInJhaW5ib3cuY2hlZXRhaC5nby5zbXMiXQ.."));
                                        startActivity(myWebLink);               

                                        Button btn = (Button) findViewById(R.id.twitter);
                                        btn.setOnClickListener(new OnClickListener() {
                                                public void onClick(View v) {
                                                        Intent myWebLink = new Intent(android.content.Intent.ACTION_VIEW);
                                                        myWebLink.setData(Uri.parse("https://twitter.com/#!/Stealthychief"));
                                                        startActivity(myWebLink);






                        Button btn = (Button) findViewById(R.id.google);
                        btn.setOnClickListener(new OnClickListener() {
                                public void onClick(View v) {
                                        Intent myWebLink = new Intent(android.content.Intent.ACTION_VIEW);
                                        myWebLink.setData(Uri.parse("https://plus.google.com/u/0/105194414710791941012/posts"));
                                        startActivity(myWebLink);     }
                        });           
                  }
                });
    }


    });

    }
        });

}});

    }};
4

1 回答 1

0

这是因为您完全弄乱了括号。我想你的意思是这样的:

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

        Button btn = (Button) findViewById(R.id.More);
        btn.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                Intent myWebLink = new Intent(
                        android.content.Intent.ACTION_VIEW);
                myWebLink.setData(Uri
                        .parse("https://play.google.com/store/search?q=stealthychief&c=apps"));
                startActivity(myWebLink);
            }
        });

        Button btn2 = (Button) findViewById(R.id.match);
        btn2.setOnClickListener(new OnClickListener() {
                public void onClick(View v) {
                        Intent myWebLink = new Intent(android.content.Intent.ACTION_VIEW);
                        myWebLink.setData(Uri.parse("https://play.google.com/store/search?q=rainbow+cheetah+stealthychief&c=apps"));
                        startActivity(myWebLink);
                }
        });

        Button btn3 = (Button) findViewById(R.id.rate);
        btn3.setOnClickListener(new OnClickListener() {
                public void onClick(View v) {
                        Intent myWebLink = new Intent(android.content.Intent.ACTION_VIEW);
                        myWebLink.setData(Uri.parse("https://play.google.com/store/apps/details?id=rainbow.cheetah.go.sms&feature=search_result#?t=W251bGwsMSwxLDEsInJhaW5ib3cuY2hlZXRhaC5nby5zbXMiXQ.."));
                        startActivity(myWebLink);
                }
        });

        Button btn4 = (Button) findViewById(R.id.twitter);
        btn4.setOnClickListener(new OnClickListener() {
                public void onClick(View v) {
                        Intent myWebLink = new Intent(android.content.Intent.ACTION_VIEW);
                        myWebLink.setData(Uri.parse("https://twitter.com/#!/Stealthychief"));
                        startActivity(myWebLink);
                }
        });

        Button btn5 = (Button) findViewById(R.id.google);
        btn5.setOnClickListener(new OnClickListener() {
                public void onClick(View v) {
                        Intent myWebLink = new Intent(android.content.Intent.ACTION_VIEW);
                        myWebLink.setData(Uri.parse("https://plus.google.com/u/0/105194414710791941012/posts"));
                        startActivity(myWebLink); 
                }
        });

    }
}
于 2012-04-21T16:46:29.537 回答