Wyświetlanie obrazu w widoku podobnym do recyklera facebook timeline

głosy
1

I 'm tworzenie aplikacji Android, siedzę w jednym punkcie. Chcę, aby wyświetlić posty jak to zostanie wyświetlony w facebook timeline. Post może mieć obrazy lub nie. Stworzyłem widok karty dla innych elementów wątku i jestem w stanie wyświetlić je w postach. Mam łącza obrazu przesyłanego z serwera dla obrazów post, teraz chcę, aby pobrać obrazy i wyświetlane na konkretnym stanowisku, które ma obraz w nim. Jak mogę to zrobić? Jeśli użytkownik ma 10 wiadomości, nie może być obraz w jednej lub dwóch osób. Jak mogę sprawdzić, które post ma obrazu, a następnie wyświetlić obraz na tym stanowisku po pobraniu go. Może ktoś mi pomóc w tej sprawie.

Proszę dać mi znać, jeśli potrzebujesz więcej informacji. Moim zdaniem karta jest jak pokazano poniżej:

<?xml version=1.0 encoding=utf-8?>
<RelativeLayout xmlns:android=http://schemas.android.com/apk/res/android
    android:layout_width=match_parent
    android:layout_height=match_parent
    android:orientation=vertical>

<android.support.v7.widget.CardView
    xmlns:card_view=http://schemas.android.com/apk/res-auto
    android:id=@+id/card_view
    android:layout_gravity=center
    android:layout_width=match_parent
    android:layout_height=wrap_content
    card_view:cardCornerRadius=4dp>

    <RelativeLayout
        android:layout_width=wrap_content
        android:layout_height=wrap_content>

    <ImageView
        android:id=@+id/imageViewUser
        android:layout_width=wrap_content
        android:layout_height=wrap_content
        android:src=@mipmap/human_image/>

    <TextView
        android:id=@+id/textViewTitle
        android:layout_width=wrap_content
        android:layout_height=wrap_content
        android:layout_toRightOf=@+id/imageViewUser
        android:layout_toEndOf=@+id/imageViewUser
        android:textSize=18sp
        android:text=titleText
        android:layout_marginLeft=10dp
        android:layout_marginStart=10dp/>

        <TextView
            android:id=@+id/textViewNoOfDays
            android:layout_width=wrap_content
            android:layout_height=wrap_content
            android:layout_below=@+id/textViewTitle
            android:textSize=14sp
            android:layout_marginLeft=10dp
            android:text=No of Days
            android:layout_toRightOf=@+id/imageViewUser
            android:layout_alignBottom=@+id/imageViewUser/>

        <TextView
            android:id=@+id/textViewPostDescription
            android:layout_width=wrap_content
            android:layout_height=wrap_content
            android:layout_below=@+id/imageViewUser
            android:layout_marginTop=20dp
            android:text=ABCDE
            android:layout_marginLeft=20dp
            android:layout_marginStart=20dp/>

        <View
            android:layout_width=fill_parent
            android:layout_height=2dp
            android:background=#c0c0c0
            android:layout_below=@+id/postImage
            android:layout_marginTop=10dp/>

        <ImageButton
            android:id=@+id/imageButtonPin
            android:layout_width=wrap_content
            android:layout_height=wrap_content
            android:layout_alignParentRight=true
            android:src=@mipmap/ic_pin_grey600_18dp/>

        <ImageView
            android:id=@+id/postImage
            android:layout_width=wrap_content
            android:layout_height=wrap_content
            android:layout_below=@+id/textViewPostDescription
            />








    </RelativeLayout>






</android.support.v7.widget.CardView>




</RelativeLayout>
Utwórz 29/11/2015 o 09:58
źródło użytkownik
W innych językach...                            


2 odpowiedzi

głosy
0

Myślę, że jest to jedno szukasz, facebook podoba cardview. Przetestować to, czy obraz pobrać z serwera null. To jest wrażliwy na rozmiar zdjęć, jak również.

Odpowiedział 21/06/2016 o 10:49
źródło użytkownik

głosy
0

W ten sposób udało mi się uzyskać tej pracy.

Adapter Class:

public class StoriesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {

    private List<Success> successList;
    ImageLoader imageLoader = AppController.getInstance().getImageLoader();
    private Context mContext;

    public StoriesAdapter(Context context, List<Success> successList) {
        this.successList = successList;
        this.mContext = context;
    }
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.success_list, parent, false);
        StoryItemViewHolder vh = new StoryItemViewHolder(v);

        return vh;
    }
    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) {
        if (imageLoader == null)
            imageLoader = AppController.getInstance().getImageLoader();
        final Success success = successList.get(position);
        StoryItemViewHolder holder = (StoryItemViewHolder) viewHolder;
        // Feed image
        if (!success.getThumbnailUrl().equals("null")) {//check if null
            holder.thumbNail.setImageUrl(success.getThumbnailUrl(), imageLoader);
            holder.thumbNail.setVisibility(View.VISIBLE);
            holder.thumbNail.setResponseObserver(new FeedImageView.ResponseObserver() {
                        @Override
                        public void onError() {
                        }

                        @Override
                        public void onSuccess() {
                        }
                    });
        } else {
            holder.thumbNail.setVisibility(View.GONE);
        }

    }
    @Override
    public int getItemCount() {
        return (null != successList ? successList.size() : 0);
    }

}

A viewHolder:

public class StoryItemViewHolder extends RecyclerView.ViewHolder {
    public FeedImageView thumbNail;

    public StoryItemViewHolder(View view) {
        super(view);
        this.thumbNail= (FeedImageView) view.findViewById(R.id.newsImage);
    }

}
Odpowiedział 21/06/2016 o 11:02
źródło użytkownik

Cookies help us deliver our services. By using our services, you agree to our use of cookies. Learn more