salman code example

Example 1: salman

GET /users/?format=api

Example 2: salman

expandablePlaceHolderView.addView(new ChildView(this, movie));

Example 3: salman

expandablePlaceHolderView.addView(new HeaderView(this, "header"));

Example 4: salman

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.velmurugan.expandablerecyclerviewexample.MainActivity">

    <com.mindorks.placeholderview.ExpandablePlaceHolderView
        android:id="@+id/expandablePlaceHolder"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    </com.mindorks.placeholderview.ExpandablePlaceHolderView>

</LinearLayout>

Example 5: salman

@Parent
@SingleTop
@Layout(R.layout.header_layout)
public class HeaderView {

    private static String TAG = "HeaderView";

    @View(R.id.header_text)
    TextView headerText;

    private Context mContext;
    private String mHeaderText;

    public HeaderView(Context context,String headerText) {
        this.mContext = context;
        this.mHeaderText = headerText;
    }

    @Resolve
    private void onResolve(){
        headerText.setText(mHeaderText);
    }

    @Expand
    private void onExpand(){
        Toast.makeText(mContext, "onExpand "+mHeaderText, Toast.LENGTH_SHORT).show();
    }

    @Collapse
    private void onCollapse(){
        Toast.makeText(mContext, "onCollapse "+mHeaderText, Toast.LENGTH_SHORT).show();
    }
}

Example 6: salman

<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="60dp"
    android:layout_margin="5dp"
    android:elevation="5dp"
    app:cardBackgroundColor="@color/colorPrimaryDark"
    app:cardCornerRadius="8dp">

    <TextView
        android:id="@+id/header_text"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="center_vertical"
        android:gravity="center_vertical"
        android:padding="10dp"
        android:textAppearance="@style/TextAppearance.AppCompat.Large"
        android:textColor="@android:color/white"
        android:textStyle="bold"
        tools:text="@tools:sample/full_names" />

</androidx.cardview.widget.CardView>

Example 7: salman

@Layout(R.layout.child_layout)
public class ChildView {
    private static String TAG ="ChildView";

    @View(R.id.child_name)
    TextView textViewChild;


    @View(R.id.child_image)
    ImageView childImage;

    private Context mContext;
    private Movie movie;

    public ChildView(Context mContext, Movie movie) {
        this.mContext = mContext;
        this.movie = movie;
    }

    @Resolve
    private void onResolve(){
        textViewChild.setText(movie.getName());
        Glide.with(mContext).load(movie.getImageUrl()).into(childImage);
        textViewChild.setOnClickListener(new android.view.View.OnClickListener() {
            @Override
            public void onClick(android.view.View v) {
                Toast.makeText(mContext, movie.getName(), Toast.LENGTH_SHORT).show();
            }
        });
    }
}

Example 8: salman

<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:card_view="http://schemas.android.com/apk/res-auto"
  xmlns:tools="http://schemas.android.com/tools"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  android:id="@+id/card_view"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:padding="5dp"
    android:elevation="5dp"
  app:cardBackgroundColor="@color/colorPrimary"
  android:layout_marginLeft="20dp"
  android:layout_marginTop="5dp"
  android:layout_marginBottom="5dp"
  android:layout_marginRight="5dp"
  card_view:cardCornerRadius="10dp">


    <androidx.constraintlayout.widget.ConstraintLayout
      android:layout_width="match_parent"
      android:layout_height="wrap_content">

        <ImageView
            android:id="@+id/child_image"
            android:layout_width="70dp"
            android:layout_height="70dp"
            android:scaleType="centerCrop"
            tools:src="@tools:sample/backgrounds/scenic"
            card_view:layout_constraintTop_toTopOf="parent"
            card_view:layout_constraintStart_toStartOf="parent"

            />

        <TextView
            android:id="@+id/child_name"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_alignParentEnd="true"
            android:layout_marginStart="8dp"
            android:layout_marginEnd="8dp"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="@android:color/white"
            android:textStyle="bold"
            card_view:layout_constraintBottom_toBottomOf="@+id/child_image"
            card_view:layout_constraintEnd_toEndOf="parent"
            card_view:layout_constraintStart_toEndOf="@+id/child_image"
            card_view:layout_constraintTop_toTopOf="@+id/child_image"
            tools:text="@tools:sample/full_names" />

    </androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>

Example 9: salman

public interface ApiInterface {
  @GET("movielist.json")
  Call<List<Movie>> getAllMovies();
}

Example 10: salman

implementation 'com.mindorks:placeholderview:0.7.1'

Tags:

Misc Example