2017-03-18 8 views
0

나는 작은 질문이있다. 내 테이블 행에서는 FacebookProfilePictureView를 추가하고 싶습니다. 간단한 ImageView를 추가하는 것과는 달리 몇 가지 오류가 발생합니다. 내가받는 출력을 보여주는 그림을 첨부하고 있습니다.동적으로 페이스 북 프로필 추가 테이블 행의 그림보기 android

enter image description here

일련 번호의 오른쪽에있는 흰색 상자는 profilepicview이 모든 시간을 설정 곳입니다. 또한, xml에서 크기를 50,50 (너비, 높이)로 설정했지만 Java에서는 지저분 해집니다. 내 코드는 아래와 같습니다.

XML 코드 :

<TableLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/view_below_linear_layout_three_team_spuck" 
    android:id="@+id/the_maintable_team_spuck" 
    > 

    <TableRow 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:id="@+id/the_maintable_row_team_spuck"> 

     <com.facebook.login.widget.ProfilePictureView 
      android:id="@+id/profile_pic_view_team_spuck" 
      android:layout_width="50dp" 
      android:layout_height="50dp" 
      android:visibility="gone" 
      android:layout_alignParentTop="true" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentStart="true" /> 

    </TableRow> 
</TableLayout> 

자바 코드 :

the_normal_image_view = new ImageView(view.getContext()); // this is the normal image view, no issues when adding this in table 
profilePictureView = new ProfilePictureView(view.getContext()); // this is the profile pic view 


the_maintable_row_team_spuck.removeAllViews(); 
the_maintable_row_team_spuck.setLayoutParams(new TableRow.LayoutParams 
     (TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.MATCH_PARENT)); 

the_maintable_row.setBackgroundResource(R.drawable.cell_shape); 


/*the_smallperson_team_spuck.setImageResource(R.drawable.the_smallperson); 
the_smallperson_team_spuck.setPadding(7, 7, 15, 0);*/ 


profilePictureView.setPadding(7, 7, 15, 0); 

//the_maintable_row.addView(the_normal_image_view); // adding normal image view into row 
the_maintable_row.addView(profilePictureView);   // adding fb profile pic view in to row 

the_maintable.addView(the_maintable_row_team_spuck, new TableRow.LayoutParams 
     (TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.MATCH_PARENT)); 

어떤 도움을 주시면 감사하겠습니다, 감사합니다 :) 당신이 그런 이미지 뷰에 대한 사용자 프로필 이미지를 당신이해야로드하려면

답변

1

이것을 사용해보십시오

1 단계 이마 때 개방 화면

new DownloadImage(imgUserProfile).execute(userProfileUrl); 

3 단계 MainActivity.java

super.onCreate(savedInstanceState); 
setContentView(R.layout.activity_home); 
ImageView imgUserProfile; 
imgUserProfile = (ImageView).findViewById(R.id.profile_image); 

4 단계 방법 geView는

<ImageView 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/profile_image" 
    android:layout_width="80dp" 
    android:layout_height="80dp" 
    android:src="@drawable/back" 
    app:civ_border_width="2dp" 
    app:civ_border_color="@color/colorWhite"/> 

에서 OnCreate 방법에 라인을 넣어 2 단계는 이미지를로드 AcyncTask Mehod 이름 : DownloadImage()

public class DownloadImage extends AsyncTask<String, Void, Bitmap> { 
    CircleImageView bmImage; 

    public DownloadImage(ImageView bmImage) { 
     this.bmImage = (CircleImageView) bmImage; 
    } 

    protected Bitmap doInBackground(String... urls) { 
     String urldisplay = urls[0]; 
     Bitmap mIcon11 = null; 
     try { 
      InputStream in = new java.net.URL(urldisplay).openStream(); 
      mIcon11 = BitmapFactory.decodeStream(in); 
     } catch (Exception e) { 
      Log.d("Error", e.getStackTrace().toString()); 

     } 
     return mIcon11; 
    } 

    protected void onPostExecute(Bitmap result) { 
     bmImage.setImageBitmap(result); 
    } 
} 
+0

친구에게 ID가 있다면 어떻게 될까요? –

+0

친구의 이드를 어디에서 사용하나요? 프로필 사진을보기 만하면 되겠습니까? –

+0

우리는 친구 IDS를 사용하여 그림을 얻을 수 있습니다 ... –