Last active
September 13, 2016 10:09
-
-
Save ashokslsk/59488f02db24ebd83450289e0b0f9ff7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" | |
android:id="@+id/card_view" | |
android:layout_width="match_parent" | |
android:layout_height="80dp" | |
android:layout_marginBottom="8dp" | |
android:layout_marginLeft="16dp" | |
android:layout_marginRight="16dp" | |
android:background="#C5CAE9" | |
android:foreground="?attr/selectableItemBackground" | |
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> | |
<LinearLayout | |
android:orientation="vertical" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:gravity="center"> | |
<TextView | |
android:id="@+id/list_title" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:layout_centerVertical="true" | |
android:layout_marginLeft="16dp" | |
android:text="Androidwarriors " | |
android:textAppearance="?attr/textAppearanceListItem" | |
android:textColor="#000000" | |
android:textSize="16sp" /> | |
<TextView | |
android:id="@+id/list_desc" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:layout_below="@+id/list_title" | |
android:layout_marginLeft="16dp" | |
android:ellipsize="end" | |
android:singleLine="true" | |
android:text="Place to dive into android programming" | |
android:textAppearance="?attr/textAppearanceListItem" | |
android:textColor="#000000" | |
android:textSize="14sp" /> | |
<TextView | |
android:id="@+id/list_Location" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:layout_below="@+id/list_desc" | |
android:layout_marginLeft="16dp" | |
android:ellipsize="end" | |
android:singleLine="true" | |
android:text="Place to dive into android programming" | |
android:textAppearance="?attr/textAppearanceListItem" | |
android:textColor="#000000" | |
android:textSize="14sp" /> | |
</LinearLayout> | |
</android.support.v7.widget.CardView> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<RelativeLayout 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=".MainActivity"> | |
<android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android" | |
android:id="@+id/my_recycler_view" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:clipToPadding="false" | |
android:paddingBottom="16dp" | |
android:paddingTop="16dp" | |
android:scrollbars="vertical" /> | |
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MainActivity extends AppCompatActivity { | |
RecyclerView recyclerView; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
recyclerView = (RecyclerView) findViewById(R.id.my_recycler_view); | |
RecyclerAdapter adapter = new RecyclerAdapter(this); | |
recyclerView.setAdapter(adapter); | |
recyclerView.setHasFixedSize(true); | |
recyclerView.setLayoutManager(new LinearLayoutManager(this)); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RecyclerAdapter extends RecyclerView.Adapter<RecyclerViewHolder> { | |
String[] jcompanyname = {"Androidwarriors", "Stackoverflow", "Cool Company", "AndroidHive", | |
"Slidenerd", "TheNewBoston", "Truiton", "HmkCode", "JavaTpoint", "Javapeper"}; | |
String[] jDesignation = {"Android Developer", "Senior Backend Developer", "Android Developer", "ios Developer", | |
"Hybrid Developer", "Android developer", "ios Developer", "Full stack Developer ", "Android Developer", "ios Develoepr"}; | |
String[] Jlocationname = {"Bangalore", "Noida", "california", "silicon valley", | |
"chennai", "Noida", "gurgaon", "kochi", "Bangalore", "Mysore"}; | |
Context context; | |
LayoutInflater inflater; | |
public RecyclerAdapter(Context context) { | |
this.context = context; | |
inflater = LayoutInflater.from(context); | |
} | |
@Override | |
public RecyclerViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { | |
View v = inflater.inflate(R.layout.row_layout, parent, false); | |
RecyclerViewHolder viewHolder = new RecyclerViewHolder(v); | |
return viewHolder; | |
} | |
@Override | |
public void onBindViewHolder(RecyclerViewHolder holder, int position) { | |
holder.mRole.setText(jDesignation[position]); | |
holder.mEmployer.setText(jcompanyname[position]); | |
holder.mLocation.setText(Jlocationname[position]); | |
} | |
View.OnClickListener clickListener = new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
RecyclerViewHolder vholder = (RecyclerViewHolder) v.getTag(); | |
int position = vholder.getPosition(); | |
Toast.makeText(context, "This is position " + position, Toast.LENGTH_LONG).show(); | |
} | |
}; | |
@Override | |
public int getItemCount() { | |
return jcompanyname.length; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RecyclerViewHolder extends RecyclerView.ViewHolder { | |
TextView mRole,mEmployer,mLocation; | |
public RecyclerViewHolder(View itemView) { | |
super(itemView); | |
mRole= (TextView) itemView.findViewById(R.id.list_title); | |
mEmployer= (TextView) itemView.findViewById(R.id.list_desc); | |
mLocation= (TextView) itemView.findViewById(R.id.list_Location); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment