Anzeigebild in Recycler Ansicht ähnlich Facebook Timeline

stimmen
1

Ich bin ein Android-Anwendung zu schaffen, bin ich an einem Punkt fest. Ich mag Beiträge anzuzeigen, wie es in Facebook-Timeline angezeigt wird. Post kann Bilder haben oder auch nicht. Ich habe eine Karte Ansicht für andere Postelemente erstellt und ich bin in der Lage, sie in Beiträgen angezeigt werden soll. Ich habe die Links Bild vom Server für die Post-Bilder gesendet, jetzt will ich Bilder herunterladen und auf bestimmte Stelle anzuzeigen, die Bild in ihm hat. Wie kann ich das machen? Wenn der Benutzer 10 Beiträge hat, kann es in einer oder zwei Bild sein. Wie kann ich überprüfen, welche Post Bild hat und dann in diesem Beitrag zeigt das Bild nach dem Download. Kann man in dieser mir bitte helfen.

Bitte lassen Sie mich wissen, wenn Sie mehr Informationen benötigen. Meine Karte Ansicht ist, wie unten dargestellt:

<?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>
Veröffentlicht am 29/11/2015 um 09:58
quelle vom benutzer
In anderen Sprachen...                            


2 antworten

stimmen
0

Ich denke , das ist die, die Sie suchen, facebook gefällt cardview. Es testet , ob das Bild holt von dem Server ist null. Dies ist eine Reaktion auf Bilder als auch Größe.

Beantwortet am 21/06/2016 um 10:49
quelle vom benutzer

stimmen
0

Dies ist, wie ich es geschafft, diese Funktion zu erhalten.

Adapter Klasse:

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

}

Und die viewHolder:

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

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

}
Beantwortet am 21/06/2016 um 11:02
quelle vom benutzer

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