जावा और एंड्रॉइड को समझने की कोशिश करना एक बटन पर क्लिक करने के बाद उपयोगकर्ता ब्राउज़र खोलने के एक साधारण कार्य में मदद करना चाहता है।वेब पेज पर ब्राउज़र खोलें एंड्रॉइड ऐप
मैं पिछले दो दिनों से ट्यूटोरियल कर रहा हूं हालांकि यह मदद कर सकता है अगर मैंने अभी इसमें एक स्टैब लिया और प्रतिक्रिया प्राप्त की। किसी भी सहायता के लिए अग्रिम रूप से धन्यवाद।
main.xml:
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bgimage2">
>
<Button
android:id="@+id/goButton"
android:layout_width="150px"
android:layout_height="wrap_content"
android:text="@string/start"
android:layout_x="80px"
android:layout_y="21px"
>
</AbsoluteLayout>
GetURL.java:
package com.patriotsar;
import android.app.Activity;
import android.content.Intent;
import android.view.View.OnClickListener;
String url = "http://www.yahoo.com";
Intent i = new Intent(Intent.ACTION_VIEW);
Uri u = Uri.parse(url);
i.setData(u);
public class patriosar extends Activity {
private Button goButton;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
goButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v){
try {
// Start the activity
startActivity(i);
} catch (ActivityNotFoundException e) {
// Raise on activity not found
Toast toast = Toast.makeText(context, "Browser not found.", Toast.LENGTH_SHORT);
}
}
});
}
}
तो ... सवाल क्या है? क्या कोड काम करता है? क्या कोड विफल रहता है? क्या होता है? – trutheality
इसके अलावा, 'AbsoluteLayout' से छुटकारा पाएं। उस कंटेनर वर्ग को बहिष्कृत किया गया है। कुछ और प्रयोग करें। – CommonsWare
@trutheality कोई कोड एमुलेटर में नहीं चलाएगा। मैं अगली पोस्ट में अपनी त्रुटियों को पोस्ट करना सुनिश्चित कर दूंगा। – Denoteone