Placing the fetched username in nav header in Navigation drawer activityDisplaying fetched profile picture in Navigation drawer activityAndroid — SurfaceView assigned from findViewById(R…) won't allow access to custom fieldsNavigation Drawer (Google+ vs. YouTube)Same Navigation Drawer in different ActivitiesCan someone show me a simple working implementation of PagerSlidingTabStrip?Navigation drawer: How do I set the selected item at startup?Activity with DrawerLayout not added to back stackTab bar application with Menu ItemOpen camera application androidHow to read Heart rate from Android WearHow to show both hamburger icon and app icon in actionbar?
Make symbols atomic, without losing their type
Large-n limit of the distribution of the normalized sum of Cauchy random variables
Story of a Witch Boy
Why is Havana covered in 5-digit numbers in Our Man in Havana?
In the US, can a former president run again?
Scaling an object to change its key
Are there any individual aliens that have gained superpowers in the Marvel universe?
If the mass of the Earth is decreasing by sending debris in space, does its angular momentum also decrease?
How can I ping multiple IP addresses at the same time?
In a list with unique pairs A, B, how can I sort them so that the last B is the first A in the next pair?
Print the new site header
Why is it 出差去 and not 去出差?
Synaptic Static - when to roll the d6?
What is this plant I saw for sale at a Romanian farmer's market?
Is Newton's third law really correct?
How can I restore a master database from its bak file?
How to best clean this sealed rotary encoder / volume knob?
How much steel armor can you wear and still be able to swim?
「捨ててしまう」why is there two て’s used here?
Is using legacy mode instead of UEFI mode a bad thing to do?
Counterfeit checks were created for my account. How does this type of fraud work?
What preparations would Hubble have needed to return in a Shuttle?
"Prove that ∂A is closed given ∂A = Cl(A) − Int(A)"
What does it cost to buy a tavern?
Placing the fetched username in nav header in Navigation drawer activity
Displaying fetched profile picture in Navigation drawer activityAndroid — SurfaceView assigned from findViewById(R…) won't allow access to custom fieldsNavigation Drawer (Google+ vs. YouTube)Same Navigation Drawer in different ActivitiesCan someone show me a simple working implementation of PagerSlidingTabStrip?Navigation drawer: How do I set the selected item at startup?Activity with DrawerLayout not added to back stackTab bar application with Menu ItemOpen camera application androidHow to read Heart rate from Android WearHow to show both hamburger icon and app icon in actionbar?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
What I have achieved- Fetching username from Facebook and displaying in different activity(working good).
What I'm working on and couldn't get it to work- I'm working on Navigation drawer activity exactly like the below one and this activity(more or less) is provided by android studio itself
I hope you can notice there is a username of this random guy in this above pic,this guy has hard-coded his name in text-view which I don't want to do, instead I want to fetch it from Facebook after login.I can successfully do the second part(fetching the name from Facebook) I just don't no how to assign let me know if there is any possible way to do it.the below is the nav_header.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="@dimen/nav_header_height"
android:background="@drawable/side_nav_bar"
android:gravity="bottom"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="@dimen/nav_header_vertical_spacing"
android:src="@android:drawable/sym_def_app_icon" />
<TextView
android:id="@+id/manner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/nav_header_vertical_spacing"
android:text="ma"
android:textColor="@color/black"
android:textAppearance="@style/TextAppearance.AppCompat.Body1" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="android.studio@android.com" /></LinearLayout>
manner is the id where I wanted to display the fetched userName and this is the .java file
@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_testing2);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
////////Code is used to fetch the user name////////////
Bundle b = getIntent().getExtras();
////////Code is used to display the user name after fetchig it from other activity////////////
TextView facebookName = (TextView) findViewById(R.id.manner);
facebookName.setText(b.getCharSequence("name"));
/////////////////////////
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.setDrawerListener(toggle);
toggle.syncState();
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
@Override
public void onBackPressed()
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
if (drawer.isDrawerOpen(GravityCompat.START))
drawer.closeDrawer(GravityCompat.START);
else
super.onBackPressed();
@Override
public boolean onCreateOptionsMenu(Menu menu)
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.testing2, menu);
return true;
@Override
public boolean onOptionsItemSelected(MenuItem item)
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings)
return true;
return super.onOptionsItemSelected(item);
@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(MenuItem item)
// Handle navigation view item clicks here.
int id = item.getItemId();
if (id == R.id.nav_camera)
// Handle the camera action
else if (id == R.id.nav_gallery)
else if (id == R.id.nav_slideshow)
else if (id == R.id.nav_manage)
else if (id == R.id.nav_share)
else if (id == R.id.nav_send)
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return true;
}
There is no error in this code because the code perfectly works for different activity with the below text view
<TextView
android:id="@+id/manner"
android:layout_gravity="left"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text=""
android:textAppearance="?android:attr/textAppearanceMedium" />
java android xml navigation-drawer
add a comment |
What I have achieved- Fetching username from Facebook and displaying in different activity(working good).
What I'm working on and couldn't get it to work- I'm working on Navigation drawer activity exactly like the below one and this activity(more or less) is provided by android studio itself
I hope you can notice there is a username of this random guy in this above pic,this guy has hard-coded his name in text-view which I don't want to do, instead I want to fetch it from Facebook after login.I can successfully do the second part(fetching the name from Facebook) I just don't no how to assign let me know if there is any possible way to do it.the below is the nav_header.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="@dimen/nav_header_height"
android:background="@drawable/side_nav_bar"
android:gravity="bottom"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="@dimen/nav_header_vertical_spacing"
android:src="@android:drawable/sym_def_app_icon" />
<TextView
android:id="@+id/manner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/nav_header_vertical_spacing"
android:text="ma"
android:textColor="@color/black"
android:textAppearance="@style/TextAppearance.AppCompat.Body1" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="android.studio@android.com" /></LinearLayout>
manner is the id where I wanted to display the fetched userName and this is the .java file
@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_testing2);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
////////Code is used to fetch the user name////////////
Bundle b = getIntent().getExtras();
////////Code is used to display the user name after fetchig it from other activity////////////
TextView facebookName = (TextView) findViewById(R.id.manner);
facebookName.setText(b.getCharSequence("name"));
/////////////////////////
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.setDrawerListener(toggle);
toggle.syncState();
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
@Override
public void onBackPressed()
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
if (drawer.isDrawerOpen(GravityCompat.START))
drawer.closeDrawer(GravityCompat.START);
else
super.onBackPressed();
@Override
public boolean onCreateOptionsMenu(Menu menu)
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.testing2, menu);
return true;
@Override
public boolean onOptionsItemSelected(MenuItem item)
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings)
return true;
return super.onOptionsItemSelected(item);
@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(MenuItem item)
// Handle navigation view item clicks here.
int id = item.getItemId();
if (id == R.id.nav_camera)
// Handle the camera action
else if (id == R.id.nav_gallery)
else if (id == R.id.nav_slideshow)
else if (id == R.id.nav_manage)
else if (id == R.id.nav_share)
else if (id == R.id.nav_send)
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return true;
}
There is no error in this code because the code perfectly works for different activity with the below text view
<TextView
android:id="@+id/manner"
android:layout_gravity="left"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text=""
android:textAppearance="?android:attr/textAppearanceMedium" />
java android xml navigation-drawer
add a comment |
What I have achieved- Fetching username from Facebook and displaying in different activity(working good).
What I'm working on and couldn't get it to work- I'm working on Navigation drawer activity exactly like the below one and this activity(more or less) is provided by android studio itself
I hope you can notice there is a username of this random guy in this above pic,this guy has hard-coded his name in text-view which I don't want to do, instead I want to fetch it from Facebook after login.I can successfully do the second part(fetching the name from Facebook) I just don't no how to assign let me know if there is any possible way to do it.the below is the nav_header.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="@dimen/nav_header_height"
android:background="@drawable/side_nav_bar"
android:gravity="bottom"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="@dimen/nav_header_vertical_spacing"
android:src="@android:drawable/sym_def_app_icon" />
<TextView
android:id="@+id/manner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/nav_header_vertical_spacing"
android:text="ma"
android:textColor="@color/black"
android:textAppearance="@style/TextAppearance.AppCompat.Body1" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="android.studio@android.com" /></LinearLayout>
manner is the id where I wanted to display the fetched userName and this is the .java file
@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_testing2);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
////////Code is used to fetch the user name////////////
Bundle b = getIntent().getExtras();
////////Code is used to display the user name after fetchig it from other activity////////////
TextView facebookName = (TextView) findViewById(R.id.manner);
facebookName.setText(b.getCharSequence("name"));
/////////////////////////
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.setDrawerListener(toggle);
toggle.syncState();
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
@Override
public void onBackPressed()
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
if (drawer.isDrawerOpen(GravityCompat.START))
drawer.closeDrawer(GravityCompat.START);
else
super.onBackPressed();
@Override
public boolean onCreateOptionsMenu(Menu menu)
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.testing2, menu);
return true;
@Override
public boolean onOptionsItemSelected(MenuItem item)
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings)
return true;
return super.onOptionsItemSelected(item);
@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(MenuItem item)
// Handle navigation view item clicks here.
int id = item.getItemId();
if (id == R.id.nav_camera)
// Handle the camera action
else if (id == R.id.nav_gallery)
else if (id == R.id.nav_slideshow)
else if (id == R.id.nav_manage)
else if (id == R.id.nav_share)
else if (id == R.id.nav_send)
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return true;
}
There is no error in this code because the code perfectly works for different activity with the below text view
<TextView
android:id="@+id/manner"
android:layout_gravity="left"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text=""
android:textAppearance="?android:attr/textAppearanceMedium" />
java android xml navigation-drawer
What I have achieved- Fetching username from Facebook and displaying in different activity(working good).
What I'm working on and couldn't get it to work- I'm working on Navigation drawer activity exactly like the below one and this activity(more or less) is provided by android studio itself
I hope you can notice there is a username of this random guy in this above pic,this guy has hard-coded his name in text-view which I don't want to do, instead I want to fetch it from Facebook after login.I can successfully do the second part(fetching the name from Facebook) I just don't no how to assign let me know if there is any possible way to do it.the below is the nav_header.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="@dimen/nav_header_height"
android:background="@drawable/side_nav_bar"
android:gravity="bottom"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="@dimen/nav_header_vertical_spacing"
android:src="@android:drawable/sym_def_app_icon" />
<TextView
android:id="@+id/manner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/nav_header_vertical_spacing"
android:text="ma"
android:textColor="@color/black"
android:textAppearance="@style/TextAppearance.AppCompat.Body1" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="android.studio@android.com" /></LinearLayout>
manner is the id where I wanted to display the fetched userName and this is the .java file
@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_testing2);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
////////Code is used to fetch the user name////////////
Bundle b = getIntent().getExtras();
////////Code is used to display the user name after fetchig it from other activity////////////
TextView facebookName = (TextView) findViewById(R.id.manner);
facebookName.setText(b.getCharSequence("name"));
/////////////////////////
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.setDrawerListener(toggle);
toggle.syncState();
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
@Override
public void onBackPressed()
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
if (drawer.isDrawerOpen(GravityCompat.START))
drawer.closeDrawer(GravityCompat.START);
else
super.onBackPressed();
@Override
public boolean onCreateOptionsMenu(Menu menu)
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.testing2, menu);
return true;
@Override
public boolean onOptionsItemSelected(MenuItem item)
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings)
return true;
return super.onOptionsItemSelected(item);
@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(MenuItem item)
// Handle navigation view item clicks here.
int id = item.getItemId();
if (id == R.id.nav_camera)
// Handle the camera action
else if (id == R.id.nav_gallery)
else if (id == R.id.nav_slideshow)
else if (id == R.id.nav_manage)
else if (id == R.id.nav_share)
else if (id == R.id.nav_send)
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return true;
}
There is no error in this code because the code perfectly works for different activity with the below text view
<TextView
android:id="@+id/manner"
android:layout_gravity="left"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text=""
android:textAppearance="?android:attr/textAppearanceMedium" />
java android xml navigation-drawer
java android xml navigation-drawer
edited Mar 25 at 6:09
Zoe
15.6k86193
15.6k86193
asked Apr 5 '16 at 18:08
EggsyEggsy
68412
68412
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
In oncreate of the activity try this
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
TextView txtProfileName = (TextView) navigationView.getHeaderView(0).findViewById(R.id.manner);
txtProfileName.setText(userName);
I found the solution but I couldn't have done it without your help thankyou so much dude,thankyou so much what I did was I replaced the last line with ' txtProfileName.setText(b.getCharSequence("name")); '
– Eggsy
Apr 6 '16 at 5:26
navigationView.getHeaderView(0) what this part does??
– Wahdat Kashmiri
Apr 10 at 13:50
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f36433878%2fplacing-the-fetched-username-in-nav-header-in-navigation-drawer-activity%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
In oncreate of the activity try this
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
TextView txtProfileName = (TextView) navigationView.getHeaderView(0).findViewById(R.id.manner);
txtProfileName.setText(userName);
I found the solution but I couldn't have done it without your help thankyou so much dude,thankyou so much what I did was I replaced the last line with ' txtProfileName.setText(b.getCharSequence("name")); '
– Eggsy
Apr 6 '16 at 5:26
navigationView.getHeaderView(0) what this part does??
– Wahdat Kashmiri
Apr 10 at 13:50
add a comment |
In oncreate of the activity try this
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
TextView txtProfileName = (TextView) navigationView.getHeaderView(0).findViewById(R.id.manner);
txtProfileName.setText(userName);
I found the solution but I couldn't have done it without your help thankyou so much dude,thankyou so much what I did was I replaced the last line with ' txtProfileName.setText(b.getCharSequence("name")); '
– Eggsy
Apr 6 '16 at 5:26
navigationView.getHeaderView(0) what this part does??
– Wahdat Kashmiri
Apr 10 at 13:50
add a comment |
In oncreate of the activity try this
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
TextView txtProfileName = (TextView) navigationView.getHeaderView(0).findViewById(R.id.manner);
txtProfileName.setText(userName);
In oncreate of the activity try this
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
TextView txtProfileName = (TextView) navigationView.getHeaderView(0).findViewById(R.id.manner);
txtProfileName.setText(userName);
answered Apr 5 '16 at 18:24
crashOveridecrashOveride
742511
742511
I found the solution but I couldn't have done it without your help thankyou so much dude,thankyou so much what I did was I replaced the last line with ' txtProfileName.setText(b.getCharSequence("name")); '
– Eggsy
Apr 6 '16 at 5:26
navigationView.getHeaderView(0) what this part does??
– Wahdat Kashmiri
Apr 10 at 13:50
add a comment |
I found the solution but I couldn't have done it without your help thankyou so much dude,thankyou so much what I did was I replaced the last line with ' txtProfileName.setText(b.getCharSequence("name")); '
– Eggsy
Apr 6 '16 at 5:26
navigationView.getHeaderView(0) what this part does??
– Wahdat Kashmiri
Apr 10 at 13:50
I found the solution but I couldn't have done it without your help thankyou so much dude,thankyou so much what I did was I replaced the last line with ' txtProfileName.setText(b.getCharSequence("name")); '
– Eggsy
Apr 6 '16 at 5:26
I found the solution but I couldn't have done it without your help thankyou so much dude,thankyou so much what I did was I replaced the last line with ' txtProfileName.setText(b.getCharSequence("name")); '
– Eggsy
Apr 6 '16 at 5:26
navigationView.getHeaderView(0) what this part does??
– Wahdat Kashmiri
Apr 10 at 13:50
navigationView.getHeaderView(0) what this part does??
– Wahdat Kashmiri
Apr 10 at 13:50
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f36433878%2fplacing-the-fetched-username-in-nav-header-in-navigation-drawer-activity%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown