I have developed a program which is working in android studio. Three components of this program are MainActivity.java, activity_main.xml and list_item.xml as following
Asked
Active
Viewed 218 times
-2

Mohammad Ali Nematollahi
- 321
- 1
- 4
- 13
-
where is your logcat?? – Nils Feb 22 '16 at 09:10
-
Provide the error you are receiving in the Logcat when the application terminates. – Pallav Feb 22 '16 at 09:12
-
the logcat is bellow the android studio – Mohammad Ali Nematollahi Feb 22 '16 at 09:20
-
Please post UserProfile.java too – Madhavan Malolan Feb 22 '16 at 09:23
-
Post the layout `activity_user_profile` – Fabin Paul Feb 22 '16 at 09:33
-
`textView3` is not inside `activity_user_profile` or its children. Where is this textview? – Rohit5k2 Feb 22 '16 at 09:46
-
textView3 is inside the first_layout.xml – Mohammad Ali Nematollahi Feb 22 '16 at 09:53
-
@MohammadAliNematollahi: Looks like a copy paste error and you are using wrong layout in `UserProfile`. Please see my answer. – Rohit5k2 Feb 22 '16 at 09:57
2 Answers
0
You should move
TextView textView = (TextView) findViewById(R.id.textView3);
textView.setText("Welcome "+username);
to onCreateView instead of onCreate in UserProfile.java
You can look at the answer here : Difference and uses of onCreate(), onCreateView() and onActivityCreated() in fragments for detailed information.

Community
- 1
- 1

Madhavan Malolan
- 719
- 6
- 24
0
Looks like
setContentView(R.layout.activity_user_profile);
should be
setContentView(R.layout.user_activity_profile);
in UserProfile
onCreate
method because the xml you have posted is user_activity_profile.xml

Rohit5k2
- 17,948
- 8
- 45
- 57
-
-
the problem is in `UserProfile` class. Check if you have used correct layout in that and all the id's you are using in that class is inside that layout. – Rohit5k2 Feb 23 '16 at 09:13
-
You need to post code of `UserProfile.java` and the layout used inside it. You can remove rest of the posted code except the logcat. – Rohit5k2 Feb 23 '16 at 09:16