आप के रूप में "android-संपत्ति" यह टैग किया तो मुझे लगता है के लिए अपनी फ़ाइल संपत्ति फ़ोल्डर में है जा रहा हूँ। यहां:
InputStream in;
BufferedReader reader;
String line;
TextView text;
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
text = (TextView) findViewById(R.id.textView1);
in = this.getAssets().open(<your file>);
reader = new BufferedReader(new InputStreamReader(in));
line = reader.readLine();
text.setText(line);
Button next = (Button) findViewById(R.id.button1);
next.setOnClickListener(this);
}
public void onClick(View v){
line = reader.readLine();
if (line != null){
text.setText(line);
} else {
//you may want to close the file now since there's nothing more to be done here.
}
}
इसे आज़माएं। मैं यह सत्यापित करने में सक्षम नहीं हूं कि यह पूरी तरह से काम करता है, लेकिन मेरा मानना है कि यह सामान्य विचार है जिसे आप अनुसरण करना चाहते हैं। स्वाभाविक रूप से आप किसी भी R.id.textView1/button1
को उन नामों के साथ प्रतिस्थापित करना चाहते हैं जिन्हें आपने अपनी लेआउट फ़ाइल में निर्दिष्ट किया है।
इसके अलावा: अंतरिक्ष के लिए यहां बहुत कम त्रुटि जांच रही है। आप यह जांचना चाहेंगे कि आपकी संपत्ति मौजूद है और मुझे यकीन है कि पढ़ने के लिए फ़ाइल खोलने पर मुझे try/catch
ब्लॉक होना चाहिए।
संपादित करें: बिग त्रुटि, यह R.layout
नहीं है, यह R.id
मैं इस समस्या को ठीक करने के लिए मेरा उत्तर संपादित किया है है।
यदि आपकी मदद मिली है तो आप उत्तर स्वीकार कर प्रतिष्ठा भी प्राप्त कर सकते हैं। – Otra