मैं इसे बनाने की कोशिश कर रहा हूं ताकि जब मैं अपनी सूचीदृश्य में विशिष्ट आइटम क्लिक करता हूं, तो यह मुझे विशिष्ट स्क्रीन पर ले जाएगा। क्या किसी को भी यह करना आता है? मैं इसएंड्रॉइड- सूचीदृश्य क्लिक पर नई गतिविधि खोलें
इसके लिए नीचे दिए गए कोड का उपयोग कर रहा हूं। मैं सूची दृश्य के नीचे एक सिंगल बैक बटन बनाने की कोशिश कर रहा हूं। अब तक मैं इसे सूचीदृश्य में प्रत्येक प्रविष्टि पर ही प्रदर्शित कर सकता हूं, मदद की सराहना की जाएगी!
import android.app.Activity;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;
public class Advertise extends ListActivity {
/** Called when the activity is first created. */
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
// Create an array of Strings, that will be put to our ListActivity
String[] names = new String[] { "Linux", "Windows7", "Eclipse", "Suse",
"Ubuntu", "Solaris", "Android", "iPhone" };
// Use your own layout and point the adapter to the UI elements which contains the label
this.setListAdapter(new ArrayAdapter<String>(this, R.layout.advertise,
R.id.label, names));
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
// Get the item that was clicked
Object o = this.getListAdapter().getItem(position);
String keyword = o.toString();
Toast.makeText(this, "You selected: " + keyword, Toast.LENGTH_LONG)
.show();
{
}
}
}
क्या आप जानते हैं कि गतिविधि कैसे शुरू करें? क्या बैक बटन? आप बैक बटन के बारे में कुछ भी नहीं दिखाते हैं। – Falmarri
मैंने बैक बटन कोड को खेद है। यह एक्सएमएल में है। लेकिन मैंने उन्हें अपनी सामान्य स्क्रीन के लिए बनाया है। मैं बटन बेच रहा हूं = (बटन) findViewById (R.id.sell); \t \t sell.setOnClickListener (नई View.OnClickListener() { \t \t \t सार्वजनिक शून्य onClick (दृश्य देखें) { \t \t \t \t आशय myIntent = नए आशय (view.getContext(), Sell.class); \t \t \t \t स्टार्ट एक्टिविटी (myIntent); – James