だから私はこれに不慣れで、検索しましたが、すべての答えが古いようですので、私を別のスレッドにリンクしないでください。また、私が学んでいるので、できるだけ説明的になるようにしてください!
質問:ブラウザを開いて特定のサイトに移動するボタンが1つあるandroidsdkを使用してEclipseでandroidアプリケーションを作成するにはどうすればよいですか。ありがとう
-テクノ
だから私はこれに不慣れで、検索しましたが、すべての答えが古いようですので、私を別のスレッドにリンクしないでください。また、私が学んでいるので、できるだけ説明的になるようにしてください!
質問:ブラウザを開いて特定のサイトに移動するボタンが1つあるandroidsdkを使用してEclipseでandroidアプリケーションを作成するにはどうすればよいですか。ありがとう
-テクノ
もっと研究をする必要があります。あなたが学んでいることは理解しています (私たちは皆、どこかで始めましたよね?)。@Timの回答で解決するはずですが、この問題だけでなく、遭遇する可能性のあるその他の問題についても役立つリソースがいくつかあります。-Android 開発サイト: http://developer.android.com/index.html -このサイト -そしてもちろん youtube これがあなたの質問に直接答えるものではないことは理解していますが、うまくいけば自分で答えを見つけるのに役立ちます (さらに、コメントに収まるまで長い)!
アプリケーションには、レイアウト xml ファイルと Java アクティビティの 2 つの主要部分が必要です。xml には、親レイアウトとボタンが含まれます。Java ファイルは、コンテンツ ビューを xml ファイルに含まれるレイアウトに設定し、Button オブジェクトへの参照を引き出し、クリック リスナーを設定して、ユーザーがボタンを押したときにコールバックを取得します。コールバック内では、Intent を使用してブラウザーを起動し、指定された URL を開きます。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/webBtn" />
</LinearLayout>
public class MainActivity extends Activity{
Button webBtn;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.main);
webBtn = (Button) findViewById(R.id.webBtn);
webBtn.setOnClickListener(new OnClickListener() {
public void onClick(View v){
/**************************
* This Intent will tell the System
* that we want to view something
* in this case we are telling it that
* we want to view the URL that we
* pass as the second parameter.
* it will search thru the applications
* on the device and find the one(s)
* that can display this type of content.
* If there are multiples it will prompt
* the user to choose which one they'd like
* to use.
***************************/
Intent i = new Intent(Intent.ACTION_VIEW, "https://www.google.com");
startActivity(i);
}
});
}
}