Why my android app stops when i set the text value of a TextView -


मेरे पास दो लेआउट हैं पहले एक:

 <कोड> & lt; LinearLayout xmlns: एंड्रॉयड = "http://schemas.android.com/apk/res/android" एंड्रॉयड: अभिविन्यास = "क्षैतिज" एंड्रॉयड: layout_width = " Match_parent "android: layout_height =" wrap_content "& gt; & Lt; EditText एंड्रॉइड: layout_width = "match_parent" एंड्रॉइड: layout_height = "match_parent" एंड्रॉइड: id = "@ + id / edit_text_val" & gt; & Lt; / EditText & gt; & LT; बटन एंड्रॉयड: आईडी = "@ + id / जारी रखने के लिए" एंड्रॉयड: layout_width = "wrap_content" एंड्रॉयड: layout_height = "wrap_content" एंड्रॉयड: layout_weight = "1" एंड्रॉयड: पाठ = "जारी रखें" एंड्रॉयड: onClick = "newConfirm" / & gt; & Lt; / LinearLayout & gt;  

और दूसरा एक:

 <कोड> & lt; LinearLayout xmlns: एंड्रॉयड = "http://schemas.android.com/apk/res/android" एंड्रॉइड: अभिविन्यास = "क्षैतिज" एंड्रॉइड: layout_width = "match_parent" एंड्रॉइड: layout_height = "wrap_content" & gt; & Lt; TextView एंड्रॉइड: layout_width = "match_parent" android: layout_height = "match_parent" एंड्रॉइड: id = "@ + id / text_view_val" & gt; & Lt; / TextView & gt; & Lt; / LinearLayout & gt;  

जब मैं पहले लेआउट के बटन पर क्लिक करता हूं तो मैं दूसरे लेआउट पर जाता हूं और TextView के टेक्स्ट वैल्यू के रूप में सेट करना चाहता हूं जो पहले लेआउट के EditText में दर्ज स्ट्रिंग है। मैं newConfirm विधि में ऐसा करते हैं:

  सार्वजनिक शून्य newConfirm (देखें) {EditText एट = (EditText) findViewById (R.id.edit_text_val); TextView tv = (TextView) findViewById (R.id.text_view_val); tv.setText (। et.getText () toString ()); }  

लेकिन जब मैं बटन पर क्लिक करता हूं तो मेरा ऐप कार्य करना बंद कर देता है ... दुर्भाग्य से मोबाइल ऐप ने बंद कर दिया है

कोई भी विचार ??

आप अपनी पहली गतिविधि से अपने EditText के मूल्य को सीधे सेट नहीं कर सकते

आपको पहली गतिविधि से दूसरी गतिविधि तक EditText के माध्यम से आशय के मान को पास करना चाहिए और फिर आपकी दूसरी गतिविधि में आशय से प्राप्त करें और सेट करें TextView

जैसा कि नीचे का प्रयास करें:

  सार्वजनिक शून्य newConfirm (देखें) {EditText एट = (EditText) findViewById (R.id.edit_text_val); आशय इरादा = नए आशय (फिस्ट लेआउट। इस, सेकंडलेआउट। क्लास); intent.putExtra (। "मूल्य", et.getText () toString ()); startActivity (आशय); }  

<कोड> में कोड नीचे अपनी दूसरी गतिविधि लिखने में onCreate

  TextView टीवी = (TextView) findViewById (R.id। text_view_val); स्ट्रिंग मान = getIntent ()। GetString ("मान"); tv.setText (मान);  

Comments

Popular posts from this blog

asp.net - Procedure or function "Procedure name" expects a parameter "Param name" which was not supplied occurs rarely -

c# - The item with identity 'Id' already exists in the metadata collection. Parameter name: item -

c++ - Redefined variable in the other module -