Anzeige abgeholt-Profil-Bild in der Navigation drawer activity

Hoffe, Sie können feststellen, ein prof pic in diesem Bild untenAnzeige abgeholt-Profil-Bild in der Navigation drawer activity aber die random Kerl, der hat es einfach hart codiert das Bild. Ich holte den Benutzernamen, die E-mail-ID und prof pic von Facebook und hakte ich habe Benutzername und E-mail-id mit navigation drawer activity,aber ich weiß nicht, wie die Anzeige der prof_pic die holte ich mir aus Facebook, ich weiß nur nicht nicht wie zuordnen. lassen Sie mich wissen, wenn es gibt jede mögliche Art und Weise, es zu tun.die unten ist die 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/profpic"
        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" />

</LinearLayout>

- und dies ist die java-Datei, wo muss ich das Holen prof_pic aus
.java-Klasse-Datei

public class Testing2 extends AppCompatActivity
        implements NavigationView.OnNavigationItemSelectedListener {


    @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();


        NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
        navigationView.setNavigationItemSelectedListener(this);
        TextView facebookName = (TextView) navigationView.getHeaderView(0).findViewById(R.id.manner);
        TextView Email = (TextView) navigationView.getHeaderView(0).findViewById(R.id.email);
        ImageView profilePictureView = (ImageView) navigationView.getHeaderView(0).findViewById(R.id.profpic);

        ////////Code is used to display the user name after fetching it from other activity////////////
        facebookName.setText(b.getCharSequence("name"));
        Email.setText(b.getCharSequence("email"));
        profilePictureView.setProfileId();

        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();

  } 

Dies ist die .java-Datei, wo ich früher zu Holen, den Benutzernamen,die E-mail-Id und prof pic

public class SelfTrail extends AppCompatActivity implements View.OnClickListener {
private LoginButton btnLogin;
TextView facebookName;
TextView Email;
Button button;
private CallbackManager callbackManager;
private ProfilePictureView profilePictureView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FacebookSdk.sdkInitialize(getApplicationContext());
setContentView(R.layout.activity_self_trail);
findAllViewsId();
button.setOnClickListener(this);
btnLogin = (LoginButton)findViewById(R.id.login_button);
facebookName = (TextView)findViewById(R.id.name);
Email = (TextView)findViewById(R.id.Email);
profilePictureView = (ProfilePictureView)findViewById(R.id.image);
btnLogin.setReadPermissions(Arrays.asList("public_profile, email"));
callbackManager = CallbackManager.Factory.create();
if(AccessToken.getCurrentAccessToken() != null){
RequestData();
facebookName.setVisibility(View.VISIBLE);
Email.setVisibility(View.VISIBLE);
profilePictureView.setVisibility(View.VISIBLE);
}
btnLogin.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
GraphRequest request = GraphRequest.newMeRequest(
loginResult.getAccessToken(),
new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(JSONObject object, GraphResponse response) {
Log.v("Main", response.toString());
setProfileToView(object);
}
});
Bundle parameters = new Bundle();
parameters.putString("fields", "id,name,email");
request.setParameters(parameters);
request.executeAsync();
}
@Override
public void onCancel() {
}
@Override
public void onError(FacebookException exception) {
}
});
}
private void findAllViewsId() {
button = (Button) findViewById(R.id.next);
facebookName = (TextView)findViewById(R.id.name);
Email = (TextView)findViewById(R.id.Email);
profilePictureView = (ProfilePictureView)findViewById(R.id.image);
}
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(), Testing2.class);
//Create a bundle object
Bundle b = new Bundle();
//Inserts a String value into the mapping of this Bundle
b.putString("name", facebookName.getText().toString());
b.putString("email", Email.getText().toString());
b.putString("image", profilePictureView.toString());
//Add the bundle to the intent.
intent.putExtras(b);
//start the DisplayActivity
startActivity(intent);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
callbackManager.onActivityResult(requestCode, resultCode, data);
}
public void RequestData(){
GraphRequest request = GraphRequest.newMeRequest(AccessToken.getCurrentAccessToken(), new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(JSONObject jsonObject,GraphResponse response) {
JSONObject json = response.getJSONObject();
try {
if(json != null){
facebookName.setText(jsonObject.getString("name"));
Email.setText(jsonObject.getString("email"));
profilePictureView.setPresetSize(ProfilePictureView.NORMAL);
profilePictureView.setProfileId(jsonObject.getString("id"));
}
} catch (JSONException e) {
e.printStackTrace();
}
}
});
Bundle parameters = new Bundle();
parameters.putString("fields", "id,name,email");
request.setParameters(parameters);
request.executeAsync();
}
private void setProfileToView(JSONObject jsonObject) {
try {
facebookName.setText(jsonObject.getString("name"));
Email.setText(jsonObject.getString("email"));
profilePictureView.setPresetSize(ProfilePictureView.NORMAL);
profilePictureView.setProfileId(jsonObject.getString("id"));
} catch (JSONException e) {
e.printStackTrace();
}
}
}
InformationsquelleAutor Eggsy | 2016-04-07
Schreibe einen Kommentar