Kodları lütfen aşağıdaki butonları kullanarak renklendirin. Örnek: <php> echo "Selam Dünya"; </php>
Yardım
karakter kaldı

2 Sutün Olarak Göstermek

Merhaba Arkadaşlar kod alttaki gibidir felan tek sutün olarak gösteriyor fakat ben 2 sutün yanyana görüntülemek istiyorum yardımcı olabilecek arkadaşlar çok sevinirim.

package com.example.adapter;

import android.content.Context;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.app.yoga.R;
import com.app.yoga.YogaDetailsActivity;
import com.example.item.ItemYoga;
import com.example.util.PopUpAds;
import com.squareup.picasso.Picasso;

import java.util.ArrayList;


public class YogaAdapter extends RecyclerView.Adapter<YogaAdapter.ItemRowHolder> {

    private ArrayList<ItemYoga> dataList;
    private Context mContext;

    public YogaAdapter(Context context, ArrayList<ItemYoga> dataList) {
        this.dataList = dataList;
        this.mContext = context;
    }

    @NonNull
    @Override
    public ItemRowHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.row_yoga_item, parent, false);
        return new ItemRowHolder(v);
    }

    @Override
    public void onBindViewHolder(@NonNull ItemRowHolder holder, final int position) {
        final ItemYoga singleItem = dataList.get(position);
        holder.text.setText(singleItem.getYogaTitle());
        holder.SName.setText(singleItem.getYogaSTitle());
        Picasso.with(mContext).load(singleItem.getYogaImage()).into(holder.image);
        holder.lyt_parent.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                PopUpAds.ShowInterstitialAds(mContext);
                Intent intent = new Intent(mContext, YogaDetailsActivity.class);
                intent.putExtra("Id", singleItem.getId());
                mContext.startActivity(intent);
            }
        });
    }

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



    class ItemRowHolder extends RecyclerView.ViewHolder {
        ImageView image;
        TextView text, SName;
        LinearLayout lyt_parent;

        ItemRowHolder(View itemView) {
            super(itemView);
            image = itemView.findViewById(R.id.image);
            text = itemView.findViewById(R.id.text);
            SName = itemView.findViewById(R.id.textSName);
            lyt_parent = itemView.findViewById(R.id.rootLayout);
        }
    }
}




LAYOUT

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    android:id="@+id/rootLayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">
    <android.support.v7.widget.CardView
        android:id="@+id/card_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="1dp"
        card_view:cardBackgroundColor="@color/white"
        card_view:cardCornerRadius="1dp"
        card_view:cardUseCompatPadding="false"
        card_view:elevation="5dp">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:gravity="center">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@color/border"
                android:gravity="center"
                android:padding="3dp">

                <ImageView
                    android:id="@+id/image"
                    android:layout_width="match_parent"
                    android:layout_height="108dp"
                    android:contentDescription="@string/app_name"
                    android:padding="1dp"
                    android:scaleType="fitXY"
                    android:src="@drawable/yoga_sample" />
            </LinearLayout>

            <TextView
                android:id="@+id/text"
                android:layout_width="match_parent"
                android:layout_height="24dp"
                android:layout_gravity="center"
                android:gravity="center"
                android:lines="1"
                android:maxLines="1"
                android:padding="1dp"
                android:text="@string/no_item_found"
                android:textAppearance="@style/TextAppearance.AppCompat.Menu"
                android:textColor="@color/black" />
        </LinearLayout>
    </android.support.v7.widget.CardView>
</LinearLayout>

Ekli Dosyalar

+0
-0
Cevaba KatılıyorumKatılmıyorum
Cevap Yaz Yorum Yaz Arşivime Ekle Takip Et

Cevaplar

  • halitpeker adlı üyenin fotoğrafı
    1 hafta önce yazılmış
    1 hafta önce güncellenmiş
    2 cevap - 0 soru
    
    Merhaba LinearLayout'da
    android:orientation="vertical"
    
    bu kısım yerine 
    android:orientation="horizantal"
    şeklinde yaparsan herşey yan yana sıralanır.
    
    İç içe linearlyoutlar kullnarak 2 satırlık goruntu olusturabilir.
    
    Yada hiç bunlarla ugrasmadan gridwivew ile yapabilirsin