I have a problem with my RecyclerView. The problem is, the word "Pending" is not located at the right of the RecyclerView. As I'm not able to post the image due to my reputation. Below I give the link of my current RecyclerView looks like.
Then, below is my current XML code.
suggestion_list.xml
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="05dp"
android:layout_marginRight="20dp">
<TextView
android:id="@+id/tvTitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="left"
android:text="Name"
android:textColor="@color/colorAccent"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Large"
android:textStyle="bold"/>
<TextView
android:id="@+id/tvStatus"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:gravity="right"
android:text="Pending"
android:textColor="#F50808" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="05dp"
android:layout_marginRight="20dp">
<TextView
android:id="@+id/tvName"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Name"
android:textColor="@color/colorAccent" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="05dp"
android:layout_marginRight="20dp">
<TextView
android:id="@+id/tvMonth"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Month"
android:textColor="@color/colorAccent" />
</TableRow>
</LinearLayout>
</FrameLayout>
activity_my_history_list.xml
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:id="@+id/haha"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MyHistoryList">
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:maxLines="1"
android:clickable="false"
android:focusable="false"
android:longClickable="false"
android:textStyle="bold"
android:textSize="18sp"
android:textColor="#FFFFFF" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="@+id/recylcerView"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
UserAdapter.java
public class UserAdapter extends RecyclerView.Adapter<UserAdapter.ProductViewHolder> {
private Context mCtx;
private List<User> userList;
private View.OnClickListener mClickListener;
public UserAdapter(Context mCtx, List<User> userList) {
this.mCtx = mCtx;
this.userList = userList;
}
public void setClickListener(View.OnClickListener callback) {
mClickListener = callback;
}
@Override
public ProductViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
LayoutInflater inflater = LayoutInflater.from(mCtx);
View view = inflater.inflate(R.layout.suggestion_list, null);
RecyclerView.ViewHolder holder = new ProductViewHolder(view);
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mClickListener.onClick(view);
}
});
return new ProductViewHolder(view);
}
@Override
public void onBindViewHolder(ProductViewHolder holder, int position) {
User user = userList.get(position);
holder.tvTitle.setText(user.getTitle());
holder.tvStatus.setText(user.getStatus());
holder.tvName.setText(user.getName());
holder.tvMonth.setText(user.getMonth());
holder.id = user.getId();
}
@Override
public int getItemCount() {
return userList.size();
}
class ProductViewHolder extends RecyclerView.ViewHolder {
TextView tvTitle, tvName, tvMonth, tvStatus;
int id;
public ProductViewHolder(View itemView) {
super(itemView);
tvTitle = itemView.findViewById(R.id.tvTitle);
tvName = itemView.findViewById(R.id.tvName);
tvMonth = itemView.findViewById(R.id.tvMonth);
tvStatus = itemView.findViewById(R.id.tvStatus);
}
}
}
Thus, I want the word "Pending" is always at right. What is the problem actually? Any suggestion?