1

我对这段代码有点困惑,正在寻找类似的东西

Button bRate = (Button) findViewById(R.id.button7); 
bRate.setOnClickListener(new View.OnClickListener() { 
    //plus the code on the top here is my idea of the code 
}

Elipse 说有问题,我知道我需要放置我的市场链接,但按钮仍然不起作用

我无法在同一页面上发布它是原始问题的链接

使用应用程序在市场上对其进行评级

4

3 回答 3

14

您刚刚添加了您的应用程序包名称...

https://play.google.com/store/apps/details?id=your packagename

并调用使用 Intent.ACTION_VIEW

String str ="https://play.google.com/store/apps/details?id=com.zeustechnocrats.quickfoods";
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(str)));
于 2012-05-16T17:43:43.387 回答
2

这对我使用图像按钮做同样的事情很有帮助。这里是我使用的代码。

    final ImageButton mybutton = (ImageButton) findViewById(R.id.imageButton); 
    mybutton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            String str ="https://play.google.com/store/apps/details?id=ws.crandell.newspaperpuzzles";
            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(str)));

        }

    });
于 2012-11-11T06:33:48.783 回答
0

您可以使用的示例代码。

将 your_package_name 更改为 your.package.name。例如 com.example.myapp

Java 文件:

public void ratebutton(View v) {
        Intent intent = new Intent(Intent.ACTION_VIEW)
                .setData(Uri
                        .parse("https://play.google.com/store/apps/details?id=your_package_name"));
        startActivity(intent);
    }

布局文件:

<Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:onClick="ratebutton"
        android:text="@string/rate"
        android:layout_gravity="center_horizontal" />

字符串.xml:

 <string name="rate">Rate with 5 stars please</string>
于 2017-03-03T08:39:41.617 回答