My Image is Not loading ,when i was using Picaaso and Glide, And its give URL Path, when i was running the app. I also Attached the pHoto of Image which having error. I tried Everything,Even i used Glide library also.But Image was not loading and its give the app error.ALso there is no error in LOGCAT.Please help , i m new in this.
App Image Error
Master Fragment
public void initData(String authorization) {
ApiInterface apiInterface =
ApiClient.getClient().create(ApiInterface.class);
Call<List<MasterEventResponse>> call =
apiInterface.getAllDetail("Token "
+ authorization);
call.enqueue(new Callback<List<MasterEventResponse>>() {
#Override
public void onResponse(Call<List<MasterEventResponse>> call,
Response<List<MasterEventResponse>> response) {
Log.d(" MasterResponse", response.toString());
if (response.isSuccessful()) {
List<MasterEventResponse> masterResponse = response.body();
MasterEventResponse mMasterEventResponse;
for (int i = 0; i < masterResponse.size(); i++) {
String time = masterResponse.get(i).getStartTime();
Integer duration =
masterResponse.get(i).getEventDuration();
String topic = masterResponse.get(i).getTopic();
String name = masterResponse.get(i).getMasterName();
String image = masterResponse.get(i).getEventImage();
Integer id = masterResponse.get(i).getId();
mMasterEventResponse = new MasterEventResponse(id,
time, duration, topic, name, image);
masterEventResponse.add(mMasterEventResponse);
masterAdapter.notifyDataSetChanged();
} else {
Toast.makeText(context, "Something is crash.",
Toast.LENGTH_SHORT).show();
}
}
}
}
MasterAdapter
public class MasterAdapter extends
RecyclerView.Adapter<MasterAdapter.ViewHolder> {
#Override
public void onBindViewHolder(#NonNull ViewHolder holder, int position) {
holder.mTime.setText(masterEventResponse.get(position).getStartTime());
holder.mDuration.setText(Integer.toString(masterEventResponse.get(position).getEventDuration()));
holder.mDescription.setText(masterEventResponse.get(position).getTopic());
holder.mMentor.setText(masterEventResponse.get(position).getMasterName());
String url = masterEventResponse.get(position).getEventImage();
Picasso.get()
.load(url)
.resize(50, 50)
.placeholder(R.drawable.image)
.into(holder.mImage);
#Override
public int getItemCount() {
return masterEventResponse.size();
//return ();
}
public class ViewHolder extends RecyclerView.ViewHolder {
public TextView mTime;
public TextView mDuration;
public TextView mDescription;
public TextView mMentor;
public ImageView mImage;
// public LinearLayout mStatus;
public ViewHolder(#NotNull View itemView) {
super(itemView);
mTime = itemView.findViewById(R.id.tv_time);
mDuration= itemView.findViewById(R.id.tv_duration);
mDescription = itemView.findViewById(R.id.tv_detail);
mMentor = itemView.findViewById(R.id.tv_mentorName);
mImage = itemView.findViewById(R.id.img_master);
}
}
}
MOdel Class
Integer id, String masterName, Integer eventDuration,
String topic, String eventImage, String startTime) {
}
XML File
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="#style/Theme.Design.NoActionBar"
android:orientation="horizontal">
<androidx.cardview.widget.CardView
android:id="#+id/cv_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:layout_weight="1"
android:background="#BACCD1"
app:cardCornerRadius="10dp"
app:cardElevation="5dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="#+id/image"
android:layout_width="match_parent"
android:layout_height="120dp">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:background="#BACCD1"
android:layout_height="wrap_content">
<androidx.cardview.widget.CardView
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_marginRight="5dp"
android:layout_marginBottom="10dp"
app:cardCornerRadius="5dp"
app:cardElevation="2dp">
<ImageView
android:id="#+id/img_master"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="#drawable/decor"/>
</androidx.cardview.widget.CardView>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_marginLeft="10dp"
android:background="#BACCD1"
android:layout_marginRight="10dp"
android:layout_marginBottom="10dp"
android:layout_marginTop="5dp">
<TextView
android:id="#+id/tv_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="10:45AM"
android:layout_marginRight="50dp"
android:textSize="18sp"
android:textColor="#android:color/black"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:orientation="horizontal">
<TextView
android:id="#+id/tv_detail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Train your mind and get richer.."
android:textStyle="bold"
android:textColor="#color/black"
android:textSize="12sp"
android:layout_marginLeft="5sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:orientation="horizontal">
<TextView
android:id="#+id/tv_mentorName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Sadhna Gupta"
android:layout_marginTop="35dp"
android:textColor="#color/black"
android:textSize="12sp"
android:layout_marginLeft="5sp" />
</LinearLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_alignParentBottom="true"
android:gravity="center_vertical">
<LinearLayout
android:id="#+id/ll_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal">
<ImageView
android:id="#+id/img_corps"
android:layout_width="15dp"
android:layout_height="15dp"
android:src="#drawable/ic_corporate"
/>
<TextView
android:id="#+id/tv_corps"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Corporate"
android:textColor="#color/black"
android:textSize="12sp"
android:layout_marginLeft="5sp" />
</LinearLayout>
<LinearLayout
android:id="#+id/lnl_restaurant"
android:layout_width="wrap_content"
android:layout_height="20dp"
android:orientation="horizontal"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:gravity="center"
android:background="#drawable/ic_join">
<TextView
android:id="#+id/tv_join"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Join"
android:textColor="#845247"
android:textSize="12sp"/>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
</LinearLayout>
<RelativeLayout
android:id="#+id/lnl_favorite"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_margin="10dp"
android:layout_alignParentRight="true">
<TextView
android:id="#+id/tv_duration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="40 min"
android:layout_alignParentTop="true"/>
</RelativeLayout>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
</androidx.cardview.widget.CardView>
Related
This question already has answers here:
android.content.res.Resources$NotFoundException: String resource ID #0x0
(8 answers)
Closed 3 years ago.
RecyclerView isn't showed without setLayoutManager, but setLayoutManager makes my program crash. This method was demonstrated in all of the tutorials I have watched. Yeah, I know, there is too much code with a lot of garbage, but the error can be anywhere, so I hope you can help me(
StoreInfoPage.java (get it just like the MainActivity)
public class StoreInfoPage extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.store_info_page);
RecyclerView lastMonthSellsList = findViewById(R.id.last_month_sells_list);
ArrayList<Product> products = new ArrayList<>();
products.add(new Product(4, 5, true, true, 16000, 12000));
products.add(new Product(4, 5, true, true, 16000, 12000));
StoreSellingAdapter adapter = new StoreSellingAdapter(this, products);
lastMonthSellsList.setAdapter(adapter);
lastMonthSellsList.setLayoutManager(new LinearLayoutManager(this));
}
}
store_info_page.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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="match_parent"
android:orientation="vertical"
tools:context=".StoreInfoPage">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/textView41"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="bottom"
android:textAllCaps="false"
android:textSize="18sp"
android:textStyle="bold|italic" />
<ImageButton
android:id="#+id/imageButton"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="#android:color/transparent"
android:scaleType="fitEnd"
app:srcCompat="#android:drawable/ic_menu_info_details" />
</LinearLayout>
<View android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#android:color/darker_gray"
android:layout_marginBottom="10dp"/>
<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/textView13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/roboto_slab_bold"
android:text="Кофе 3в1"
android:textColor="#000000"
android:textSize="24sp"
android:textStyle="bold|italic" />
<EditText
android:id="#+id/editText5"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:ems="10"
android:fontFamily="#font/roboto_slab_bold"
android:inputType="number"
android:textAlignment="center" />
<TextView
android:id="#+id/textView17"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fontFamily="#font/roboto_slab_bold"
android:textColor="#000000" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/textView14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/roboto_slab_bold"
android:text="Чёрное Кофе"
android:textColor="#000000"
android:textSize="24sp"
android:textStyle="bold|italic" />
<EditText
android:id="#+id/editText6"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:ems="10"
android:fontFamily="#font/roboto_slab_bold"
android:inputType="number"
android:textAlignment="center" />
<TextView
android:id="#+id/textView18"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fontFamily="#font/roboto_slab_bold"
android:textColor="#000000" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/textView21"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/roboto_slab_bold" />
<TextView
android:id="#+id/textView16"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/roboto_slab_bold"
android:textColor="#000000" />
<TextView
android:id="#+id/textView19"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/roboto_slab_bold"
android:textColor="#000000" />
</TableRow>
</TableLayout>
<Switch
android:id="#+id/switch1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:showText="true"
android:text="ДОЛГ"
android:textAlignment="center"
android:textSize="24sp" />
<Button
android:id="#+id/button5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="#font/roboto_slab_bold"
android:text="Добавить"
android:textSize="24sp" />
<View android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#android:color/darker_gray"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"/>
<TextView
android:id="#+id/textView20"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="#font/roboto_slab_bold"
android:text="ПРОШЛЫЙ МЕСЯЦ"
android:textAlignment="center"
android:textColor="#000000"
android:textSize="30sp" />
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/last_month_sells_list"
/>
</LinearLayout>
store_sell_list_table_row.xml (Adapter xml for RecyclerView)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|top"
android:id="#+id/sells_list_adapter_layout"
android:orientation="vertical">
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/whiteCoffeeAdapter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/roboto_slab_bold"
android:text="Кофе 3в1"
android:textColor="#000000"
android:textSize="24sp" />
<TextView
android:id="#+id/whiteCoffeeQuantityAdapter"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fontFamily="#font/roboto_slab_bold"
android:text="0"
android:textColor="#000000" />
<TextView
android:id="#+id/whiteCoffeePriceAdapter"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fontFamily="#font/roboto_slab_bold"
android:text="0"
android:textColor="#000000" />
<TextView
android:id="#+id/whiteCoffeeTotalPriceAdapter"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fontFamily="#font/roboto_slab_bold"
android:text="0"
android:textColor="#000000" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/blackCoffeeAdapter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/roboto_slab_bold"
android:text="Чёрное Кофе"
android:textColor="#000000"
android:textSize="24sp"
android:textStyle="bold" />
<TextView
android:id="#+id/blackCoffeeQuantityAdapter"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fontFamily="#font/roboto_slab_bold"
android:text="0"
android:textColor="#000000" />
<TextView
android:id="#+id/blackCoffeePriceAdapter"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fontFamily="#font/roboto_slab_bold"
android:text="0"
android:textColor="#000000" />
<TextView
android:id="#+id/blackCoffeeTotalPriceAdapter"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fontFamily="#font/roboto_slab_bold"
android:text="0"
android:textColor="#000000" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/textView38"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/roboto_slab_bold"
android:textColor="#000000" />
<TextView
android:id="#+id/textView39"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fontFamily="#font/roboto_slab_bold"
android:textColor="#000000" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/coffeeTotalPriceAdapter"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fontFamily="#font/roboto_slab_bold"
android:text="0"
android:textColor="#000000" />
</TableRow>
</TableLayout>
<TextView
android:id="#+id/status_text_view_adapter"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ОПЛАЧЕНО"
android:textAlignment="center"
android:textStyle="bold" />
</LinearLayout>
StoreSellingAdapter (Adapter class)
public class StoreSellingAdapter extends RecyclerView.Adapter<StoreSellingAdapter.ViewHolder>{
private ArrayList<Product> products;
private Context context;
StoreSellingAdapter(Context context, ArrayList<Product> products) {
this.products = products;
this.context = context;
}
#NonNull
#Override
public ViewHolder onCreateViewHolder(#NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.store_sell_list_table_row, parent, false);
return new ViewHolder(view);
}
#Override
public void onBindViewHolder(#NonNull ViewHolder holder, int position) {
Product product = products.get(position);
holder.whiteCoffeeQuantity.setText(product.getWhiteCoffeeQuantity());
holder.blackCoffeeQuantity.setText(product.getBlackCoffeeQuantity());
holder.whiteCoffeePrice.setText(product.getWhiteCoffeePrice());
holder.blackCoffeePrice.setText(product.getBlackCoffeePrice());
holder.whiteCoffeeTotalPrice.setText(product.getWhiteCoffeeTotalPrice());
holder.blackCoffeeTotalPrice.setText(product.getBlackCoffeeTotalPrice());
holder.coffeeTotalPrice.setText(product.getCoffeeTotalPrice());
if(product.isDebt() && product.isPaid()) {
holder.statusTextViewAdapter.setText("ДОЛГ(ОПЛАЧЕНО)");
holder.parentLayout.setBackgroundColor(Color.parseColor("#ef5350"));
}
}
#Override
public int getItemCount() {
return products.size();
}
class ViewHolder extends RecyclerView.ViewHolder{
TextView whiteCoffeeQuantity;
TextView blackCoffeeQuantity;
TextView whiteCoffeePrice;
TextView blackCoffeePrice;
TextView whiteCoffeeTotalPrice;
TextView blackCoffeeTotalPrice;
TextView coffeeTotalPrice;
TextView statusTextViewAdapter;
LinearLayout parentLayout;
ViewHolder(#NonNull View itemView) {
super(itemView);
whiteCoffeeQuantity = itemView.findViewById(R.id.whiteCoffeeQuantityAdapter);
blackCoffeeQuantity = itemView.findViewById(R.id.blackCoffeeQuantityAdapter);
whiteCoffeePrice = itemView.findViewById(R.id.whiteCoffeePriceAdapter);
blackCoffeePrice = itemView.findViewById(R.id.blackCoffeePriceAdapter);
whiteCoffeeTotalPrice = itemView.findViewById(R.id.whiteCoffeeTotalPriceAdapter);
blackCoffeeTotalPrice = itemView.findViewById(R.id.blackCoffeeTotalPriceAdapter);
coffeeTotalPrice = itemView.findViewById(R.id.coffeeTotalPriceAdapter);
parentLayout = itemView.findViewById(R.id.sells_list_adapter_layout);
statusTextViewAdapter = itemView.findViewById(R.id.status_text_view_adapter);
}
}
}
Product.java
public class Product {
private int whiteCoffeeQuantity;
private int blackCoffeeQuantity;
private boolean isDebt;
private boolean isPaid;
private int whiteCoffeePrice;
private int blackCoffeePrice;
private int whiteCoffeeTotalPrice;
private int blackCoffeeTotalPrice;
private int coffeeTotalPrice;
public Product(int whiteCoffeeQuantity, int blackCoffeeQuantity, boolean isDebt, boolean isPaid, int whiteCoffeePrice, int blackCoffeePrice) {
this.whiteCoffeeQuantity = whiteCoffeeQuantity;
this.blackCoffeeQuantity = blackCoffeeQuantity;
this.isDebt = isDebt;
this.isPaid = isPaid;
this.whiteCoffeePrice = whiteCoffeePrice;
this.blackCoffeePrice = blackCoffeePrice;
whiteCoffeeTotalPrice = whiteCoffeeQuantity*whiteCoffeePrice;
blackCoffeeTotalPrice = blackCoffeeQuantity*blackCoffeePrice;
coffeeTotalPrice = whiteCoffeeTotalPrice+blackCoffeeTotalPrice;
}
public int getWhiteCoffeeQuantity() {
return whiteCoffeeQuantity;
}
public void setWhiteCoffeeQuantity(int whiteCoffeeQuantity) {
this.whiteCoffeeQuantity = whiteCoffeeQuantity;
}
public int getBlackCoffeeQuantity() {
return blackCoffeeQuantity;
}
public void setBlackCoffeeQuantity(int blackCoffeeQuantity) {
this.blackCoffeeQuantity = blackCoffeeQuantity;
}
public boolean isDebt() {
return isDebt;
}
public void setDebt(boolean debt) {
isDebt = debt;
}
public boolean isPaid() {
return isPaid;
}
public void setPaid(boolean paid) {
isPaid = paid;
}
public int getWhiteCoffeePrice() {
return whiteCoffeePrice;
}
public void setWhiteCoffeePrice(int whiteCoffeePrice) {
this.whiteCoffeePrice = whiteCoffeePrice;
}
public int getBlackCoffeePrice() {
return blackCoffeePrice;
}
public void setBlackCoffeePrice(int blackCoffeePrice) {
this.blackCoffeePrice = blackCoffeePrice;
}
public int getWhiteCoffeeTotalPrice() {
return whiteCoffeeTotalPrice;
}
public void setWhiteCoffeeTotalPrice(int whiteCoffeeTotalPrice) {
this.whiteCoffeeTotalPrice = whiteCoffeeTotalPrice;
}
public int getBlackCoffeeTotalPrice() {
return blackCoffeeTotalPrice;
}
public void setBlackCoffeeTotalPrice(int blackCoffeeTotalPrice) {
this.blackCoffeeTotalPrice = blackCoffeeTotalPrice;
}
public int getCoffeeTotalPrice() {
return coffeeTotalPrice;
}
public void setCoffeeTotalPrice(int coffeeTotalPrice) {
this.coffeeTotalPrice = coffeeTotalPrice;
}
}
I really don't know you!
Everything is because of TextView.setText(Int).
Just replace Int with String.valueOf(Int).
I want to make adding a Profile picture special it to the account and it's saved (store) into database - cloud Firestore as a special Profile picture for each account
for example to more explain:
there are two users use my application and all of them want special Profile picture for they Profile , how can I store this image to each of them in each database account and Display automatically if a user logs in to his Profile
following the code of the Profile java and activity
Profile.Java
public class Child_Profile extends AppCompatActivity {
private TextView name;
private TextView gender;
private TextView birth;
private TextView bload;
private TextView Text_Dates;
private TextView Text_Time;
private Button Button_record;
private TextView Text_record;
private TextView Text_hospial;
private TextView Text_Plan;
private TextView Text_Satus;
private TextView Text_Price;
private ImageView ImageView_choose_image;
private Button button_choose_image;
private Uri mUri;
private static final int GALLERY_INTENT = 1;
private StorageReference mStorage;
private DatabaseReference mData;
private FirebaseFirestore db = FirebaseFirestore.getInstance();
#Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main_menu,menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId()==R.id.action_sign_out)
signOut();
return true;
}
private void signOut() {
AuthUI.getInstance().signOut(this)
.addOnCompleteListener(new OnCompleteListener<Void>() {
#Override
public void onComplete(#NonNull Task<Void> task) {
startActivity(new Intent(Child_Profile.this,User.class));
finish();
}
});
}
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_child__profile);
name = findViewById(R.id.text_view_Namee);
gender = findViewById(R.id.text_view_Gender);
birth = findViewById(R.id.text_view_Birth);
bload = findViewById(R.id.text_view_Blood);
Text_Dates = findViewById(R.id.Text_Dates);
Text_Time = findViewById(R.id.Text_Time);
Text_record = findViewById(R.id.Text_record);
Text_hospial = findViewById(R.id.Text_hospial);
Text_Plan = findViewById(R.id.Text_Plan);
Text_Satus = findViewById(R.id.Text_Satus);
Button_record = findViewById(R.id.Button_record);
Text_Price = findViewById(R.id.Text_Price);
button_choose_image = findViewById(R.id.button_choose_image);
ImageView_choose_image = findViewById(R.id.ImageView_choose_image);
mStorage = FirebaseStorage.getInstance().getReference("Photo");
mData = FirebaseDatabase.getInstance().getReference("Photo");
button_choose_image.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
openFileChooser();
}
});
Intent in = getIntent();
final Bundle b = in.getExtras();
if (b != null) {
String n = (String) b.get("id");
db.collection("Child Profile").document(n).get()
.addOnSuccessListener(new OnSuccessListener<DocumentSnapshot>() {
#Override
public void onSuccess(DocumentSnapshot documentSnapshot) {
String pName = documentSnapshot.getString("name");
String pgender = documentSnapshot.getString("gender");
String pbirth = documentSnapshot.getString("birth");
String pbload = documentSnapshot.getString("bload");
String pDates = documentSnapshot.getString("dates");
String pTime = documentSnapshot.getString("time");
String pHospital = documentSnapshot.getString("hospital");
String pPlan = documentSnapshot.getString("typeOfPlan");
String pSatus = documentSnapshot.getString("satus");
String pPrice = documentSnapshot.getString("price");
name.setText(pName);
gender.setText(pgender);
birth.setText(pbirth);
bload.setText(pbload);
Text_Dates.setText(pDates);
Text_Time.setText(pTime);
Text_hospial.setText(pHospital);
Text_Plan.setText(pPlan);
Text_Satus.setText(pSatus);
Text_Price.setText(pPrice);
}
});
}
}
private void openFileChooser() {
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(intent, GALLERY_INTENT);
}
#Override
protected void onActivityResult(int requestCode, int resultCode, #Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == GALLERY_INTENT && resultCode == RESULT_OK && data != null && data.getData()!= null) {
mUri = data.getData();
Picasso.with(this).load(mUri).into(ImageView_choose_image);
}
}
public void ImageView_choose_image(View view) {
}
Profile.Xml
<LinearLayout
android:layout_width="match_parent"
android:layout_height="200dp"
android:background="#color/colorPrimaryDark"
android:orientation="vertical">
<ImageView
android:id="#+id/ImageView_choose_image"
android:layout_width="86dp"
android:layout_height="68dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="45dp"
android:onClick="ImageView_choose_image"/>
<Button
android:id="#+id/button_choose_image"
android:layout_width="wrap_content"
android:layout_height="68dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="-110dp"
android:background="#null"
android:text="chid Picture" />
<TextView
android:id="#+id/text_view_Namee"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="40dp"
android:text="Name"
android:textColor="#android:color/white"
android:textSize="25dp"
android:textStyle="bold" />
</LinearLayout>
<android.support.v7.widget.CardView
android:layout_width="350dp"
android:layout_height="100dp"
android:layout_marginLeft="10dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="160dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="3">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<TextView
android:id="#+id/text_view_Gender"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Gender"
android:textSize="20dp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<TextView
android:id="#+id/text_view_Birth"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Birth Day"
android:textSize="20dp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<TextView
android:id="#+id/text_view_Blood"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Blood Type"
android:textSize="20dp" />
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
<LinearLayout
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="horizontal">
<LinearLayout
android:layout_marginTop="50dp"
android:layout_width="30dp"
android:layout_height="wrap_content"
android:layout_weight="9"
android:orientation="horizontal">
<ImageView
android:layout_width="50dp"
android:layout_height="65dp"
android:background="#drawable/calendar"/>
<TextView
android:id="#+id/Text_Dates"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:text="Dates" />
<TextView
android:id="#+id/Text_Time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginLeft="-35dp"
android:text="Time" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_marginTop="240dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:layout_marginLeft="-1dp"
android:orientation="horizontal">
<LinearLayout
android:layout_marginTop="70dp"
android:layout_width="30dp"
android:layout_height="wrap_content"
android:layout_weight="9"
android:orientation="horizontal">
<ImageView
android:layout_width="50dp"
android:layout_height="65dp"
android:layout_marginTop="25dp"
android:background="#drawable/recodbook" />
<TextView
android:id="#+id/Text_Plan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:text="Plan" />
<TextView
android:id="#+id/Text_Price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:layout_marginLeft="-30dp"
android:padding="2dp"
android:text="Price" />
<TextView
android:id="#+id/Text_Satus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="-30dp"
android:padding="2dp"
android:layout_marginTop="70dp"
android:text="Satus" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:layout_marginLeft="180dp"
android:orientation="horizontal">
<LinearLayout
android:layout_marginTop="50dp"
android:layout_width="30dp"
android:layout_height="wrap_content"
android:layout_weight="9"
android:orientation="horizontal">
<Button
android:id="#+id/Button_record"
android:layout_width="50dp"
android:layout_height="65dp"
android:layout_marginLeft="20dp"
android:background="#drawable/record" />
<TextView
android:id="#+id/Text_record"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="your record" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_marginTop="250dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:layout_marginLeft="160dp"
android:orientation="horizontal">
<LinearLayout
android:layout_marginTop="70dp"
android:layout_width="30dp"
android:layout_height="wrap_content"
android:layout_weight="9"
android:orientation="horizontal">
<ImageView
android:layout_width="50dp"
android:layout_height="65dp"
android:layout_marginLeft="6dp"
android:layout_marginTop="5dp"
android:src="#drawable/medical" />
<TextView
android:id="#+id/Text_hospial"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_marginTop="25dp"
android:gravity="center"
android:text="your hospital" />
</LinearLayout>
</LinearLayout>
I am making android cv app and I have implemented RecyclerView but items not scrolling even though, I have used RecyclerViewLayout Manager.
below my SkillsAdapter.class
public class SkillsAdapter extends RecyclerView.Adapter {
public List skillList;
public Context context;
public SkillsAdapter(List<Skill> skillList, Context context) {
this.skillList = skillList;
this.context = context;
}
#NonNull
#Override
public SkillsAdapter.ViewHolder onCreateViewHolder(#NonNull ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(context)
.inflate(R.layout.skills_item, parent, false); // change
return new SkillsAdapter.ViewHolder(itemView);
}
#Override
public void onBindViewHolder(#NonNull SkillsAdapter.ViewHolder holder, int position) {
Skill skill = skillList.get(position);
holder.programming.setText(skill.getProgramming());
holder.framework.setText(skill.getFrameworkLibraries());
holder.architecture.setText(skill.getAndroidArchitectureComponents());
holder.software.setText(skill.getSoftwareMethodologies());
holder.ide.setText(skill.getIDES());
}
#Override
public int getItemCount() {
return skillList.size();
}
public class ViewHolder extends RecyclerView.ViewHolder {
public TextView programming, framework, architecture, software, ide;
public ViewHolder(View view) {
super(view);
programming= (TextView) view.findViewById(R.id.programming);
framework = (TextView) view.findViewById(R.id.framework);
architecture = (TextView) view.findViewById(R.id.architecture);
software = (TextView) view.findViewById(R.id.software);
ide = (TextView)view.findViewById(R.id.ide);
}
}
}
below my SkillsItem.java class
public class SkillItem extends AppCompatActivity {
private SkillsAdapter skillsAdapter;
public List<Skill> skillList;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.skills);
KitabInterface kitabInterface = ApiClient.getApiService();
Call<KitabSawti> call = kitabInterface.getSkills();
call.enqueue(new Callback<KitabSawti>() {
#Override
public void onResponse(Call<KitabSawti> call, Response<KitabSawti> response) {
skillList= response.body().getSkills();
RecyclerView recyclerView = findViewById(R.id.recyclerView);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getApplicationContext(), LinearLayoutManager.VERTICAL, false);
recyclerView.setLayoutManager(linearLayoutManager);
skillsAdapter = new SkillsAdapter( skillList, SkillItem.this); // changes
recyclerView.setAdapter(skillsAdapter);
}
#Override
public void onFailure(Call<KitabSawti> call, Throwable t) {
}
});
}
}
below my skills_items.xml where I have implemented items
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorBlust"
android:orientation="vertical"
android:padding="10dp">
<LinearLayout xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorBlust"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:orientation="horizontal">
<ImageView
android:id="#+id/educationImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="5dp"
android:layout_marginLeft="5dp"
android:src="#drawable/it_skills"
tools:ignore="ContentDescription" />
<TextView
android:id="#+id/education_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp"
android:text="#string/text_skills"
android:textColor="#color/colorWhite"
android:textSize="20sp" />
</LinearLayout>
</LinearLayout>
<LinearLayout xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorBlust"
android:orientation="horizontal"
android:padding="20dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageView
android:id="#+id/subjectImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="20dp"
android:layout_marginLeft="20dp"
android:src="#drawable/programming_skills"
tools:ignore="ContentDescription" />
<TextView
android:id="#+id/programming"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="100dp"
android:layout_marginLeft="100dp"
android:text="#string/programming_skills"
android:textColor="#color/colorWhite"
android:textSize="20sp" />
<View style="#style/dividerHorizontal" />
</RelativeLayout>
</LinearLayout>
<LinearLayout xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorBlust"
android:orientation="horizontal"
android:padding="20dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageView
android:id="#+id/framework_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="20dp"
android:layout_marginLeft="20dp"
android:src="#drawable/it_frameworks"
tools:ignore="ContentDescription" />
<TextView
android:id="#+id/framework"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="100dp"
android:layout_marginLeft="100dp"
android:text="#string/text_framework"
android:textColor="#color/colorWhite"
android:textSize="20sp" />
<View style="#style/dividerHorizontal" />
</RelativeLayout>
</LinearLayout>
<LinearLayout xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorBlust"
android:orientation="horizontal"
android:padding="20dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageView
android:id="#+id/android_component"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="20dp"
android:layout_marginLeft="20dp"
android:src="#drawable/android_components"
tools:ignore="ContentDescription" />
<TextView
android:id="#+id/architecture"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="100dp"
android:layout_marginLeft="100dp"
android:text="#string/architecture"
android:textColor="#color/colorWhite"
android:textSize="20sp" />
<View style="#style/dividerHorizontal" />
</RelativeLayout>
</LinearLayout>
<LinearLayout xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorBlust"
android:orientation="horizontal"
android:padding="20dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageView
android:id="#+id/software_method"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="20dp"
android:layout_marginLeft="20dp"
android:src="#drawable/software_methodologies"
tools:ignore="ContentDescription" />
<TextView
android:id="#+id/software"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="100dp"
android:layout_marginLeft="100dp"
android:text="#string/software"
android:textColor="#color/colorWhite"
android:textSize="20sp" />
<View style="#style/dividerHorizontal" />
</RelativeLayout>
</LinearLayout>
<LinearLayout xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorBlust"
android:orientation="horizontal"
android:padding="20dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageView
android:id="#+id/software_ide"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="20dp"
android:layout_marginLeft="20dp"
android:src="#drawable/software_ide"
tools:ignore="ContentDescription" />
<TextView
android:id="#+id/ide"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="100dp"
android:layout_marginLeft="100dp"
android:text="#string/ides"
android:textColor="#color/colorWhite"
android:textSize="20sp" />
<View style="#style/dividerHorizontal" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
below my skills.xml where I have hosted RecyclerView
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical" />
</RelativeLayout>
below screenshot
current ui
The problem is, that the root layout of your item (the root LinearLayout at skills_items.xml) has height of match_parent. This messes up the way RecyclerView does the scrolling event calculations.
Also, it is generally advised against using wrap_content for height or width of the root layout for an activity and for wrap_content for height (if scroll is vertical) or width (if scroll is horizontal) of RecyclerView or ListView.
I am totally familiar with ExpandableRecyclerview Or ExpandableLayout But I have a design that is a little bit unique and I am seeking help to achieve this implementation.
I Am Attaching the design
When the user clicks the arrow shown in the image the CardView Recyclerview should expand or inflate a recyclerview in between comment button and response section. How to do that. I have tried the ExpandableRecyclerview from ThoughtBot and ExpandableListView all this components add a child to parent.
I am using ExpandableRecyclerview from Thoughtbot,
com.thoughtbot.expandablerecyclerview
My Adapter Looks like as below.
public class ReviewRecyclerAdapter extends ExpandableRecyclerViewAdapter<ReviewViewHolder, CommentsViewHolder> {
private Context context;
public ReviewRecyclerAdapter(Context context,List<? extends ExpandableGroup> groups) {
super(groups);
this.context = context;
}
#Override
public ReviewViewHolder onCreateGroupViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.list_item_review, parent, false);
return new ReviewViewHolder(view);
}
#Override
public CommentsViewHolder onCreateChildViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.list_item_comments, parent, false);
return new CommentsViewHolder(view);
}
#Override
public void onBindChildViewHolder(CommentsViewHolder holder, int flatPosition, ExpandableGroup group, int childIndex) {
final CommentsModel comments = ((ReviewsModel) group).getItems().get(childIndex);
holder.setSubTitletName(comments.getComment());
}
#Override
public void onBindGroupViewHolder(ReviewViewHolder holder, int flatPosition, ExpandableGroup group) {
holder.setGenreTitle(context, group);
}
}
// View Holders
public class ReviewViewHolder extends GroupViewHolder {
private TextView titleName;
private ImageView arrow;
private ImageView icon;
public ReviewViewHolder(View itemView) {
super(itemView);
titleName = (TextView) itemView.findViewById(R.id.list_item_genre_name);
arrow = (ImageView) itemView.findViewById(R.id.list_item_genre_arrow);
}
public void setGenreTitle(Context context, ExpandableGroup title) {
if (title instanceof ReviewsModel) {
titleName.setText(title.getTitle());
if (((ReviewsModel) title).getReview()!= null && !((ReviewsModel) title).getReview().isEmpty()){
}
}
}
#Override
public void expand() {
animateExpand();
}
#Override
public void collapse() {
animateCollapse();
}
private void animateExpand() {
RotateAnimation rotate =
new RotateAnimation(360, 180, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
rotate.setDuration(300);
rotate.setFillAfter(true);
arrow.setAnimation(rotate);
}
private void animateCollapse() {
RotateAnimation rotate =
new RotateAnimation(180, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
rotate.setDuration(300);
rotate.setFillAfter(true);
arrow.setAnimation(rotate);
}
}
public class CommentsViewHolder extends ChildViewHolder {
private TextView subTitleTextView;
public CommentsViewHolder(View itemView) {
super(itemView);
subTitleTextView = (TextView) itemView.findViewById(R.id.subtitle);
}
public void setSubTitletName(String name) {
subTitleTextView.setText(name);
}
}
//Review Layout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="24dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="#+id/review_details"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<de.hdodenhof.circleimageview.CircleImageView xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/list_avatar"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="10dp"
android:src="#drawable/profile_placeholder" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginStart="16dp"
android:layout_toEndOf="#+id/list_avatar">
<TextView
android:id="#+id/list_item_genre_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:maxEms="15"
android:text=" Guru natha"
android:textStyle="bold"
android:layout_alignParentTop="true" />
<TextView
android:id="#+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxEms="15"
android:text=" From Mg Road"
android:layout_alignStart="#+id/list_item_genre_name"
android:layout_marginStart="10dp"
android:layout_below="#+id/list_item_genre_name" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true">
<TextView
android:id="#+id/days"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginStart="10dp"
android:maxEms="15"
android:text=" 3 Days ago"
android:textSize="8sp"
android:textStyle="bold" />
<TextView
android:id="#+id/count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="#+id/days"
android:layout_below="#+id/days"
android:maxEms="15"
android:text=" 448 Views"
android:textSize="8sp" />
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:id="#+id/content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/review_details"
android:layout_margin="20dp">
<TextView
android:id="#+id/review"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginStart="10dp"
android:maxEms="15"
android:text="Review"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginStart="10dp"
android:maxEms="15"
android:text="Rating"
android:textStyle="bold" />
<View
android:id="#+id/lineytf"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="#+id/review"
android:background="#color/black" />
<TextView
android:layout_marginTop="10dp"
android:id="#+id/review_conetent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="#+id/lineytf"
android:layout_below="#+id/lineytf"
android:maxLines="3"
android:maxEms="15"
android:text="#string/lorem_ipsum" />
</RelativeLayout>
<RelativeLayout
android:layout_marginLeft="30dp"
android:layout_marginRight="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/content">
<TextView
android:id="#+id/response"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginStart="30dp"
android:maxEms="15"
android:text="Response (2)"
android:textStyle="bold" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginStart="10dp"
android:maxEms="15"
android:layout_above="#+id/line2"
android:src="#drawable/white_r_arrow"
android:text="arrow"
android:textStyle="bold"
android:id="#+id/list_item_genre_arrow" />
<View
android:id="#+id/line2"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="#+id/response"
android:background="#color/black" />
<!--Add expandable views-->
<Button
android:id="#+id/commentsbutton"
android:textSize="12sp"
android:textAllCaps="false"
android:text="Comments"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_below="#+id/line2"
android:layout_toStartOf="#+id/button2" />
<Button
android:textSize="12sp"
android:textAllCaps="false"
android:text="56"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_below="#+id/list_item_genre_arrow"
android:layout_alignParentEnd="true"
android:id="#+id/button2" />
</RelativeLayout>
</RelativeLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
//Comment Layout
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="40dp">
<ImageView
android:id="#+id/list_item_genre_arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginLeft="70dp"
android:layout_alignParentRight="true"
android:src="#drawable/android" />
<TextView
android:id="#+id/subtitle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="100dp"
android:gravity="center_vertical"
tools:text="SubTitle" />
</FrameLayout>
Current Screenshot :
Please do shoot the closest solution if you have.
i have an activity which is having about 4 fragment and fragment have a recyclerview and in each recyclerview item there is a button.. i have a textfield in activity and i want to show the no. of button clicked.
thats my activity.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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="match_parent"
android:orientation="vertical"
android:weightSum="3"
tools:context="com.example.khaalijeb.newlistview_module.PromoCodeActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1.4"
android:background="#f9f9f9"
android:elevation="5dp">
<ImageView
android:id="#+id/back"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp"
android:src="#drawable/greyback" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:layout_toRightOf="#+id/back"
android:text="Fancy Some Deals ?"
android:textSize="16dp"
android:textStyle="bold" />
<Button
android:id="#+id/skip"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginBottom="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:background="#drawable/roundedcorneredittext"
android:text="SKIP"
android:textColor="#0277bd"
android:textSize="12dp" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.55"
android:orientation="vertical">
<android.support.design.widget.TabLayout
android:id="#+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabGravity="fill"
app:tabIndicatorColor="#E12728"
app:tabMode="scrollable"
app:tabSelectedTextColor="#E12728"
app:tabTextAppearance="#style/TextAppearance.Design.Tab" />
<android.support.v4.view.ViewPager
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#ffffff" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1.05"
android:background="#f9f9f9"
android:orientation="vertical"
android:weightSum="2">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:orientation="vertical"
android:weightSum="2">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1.2"
android:orientation="horizontal"
android:weightSum="2">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#727272"
/>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/TextLabel">
<EditText
android:id="#+id/spass"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:hint="Promo Code"
android:inputType="textPassword"
android:paddingLeft="10dp"
android:textColor="#color/material_blue_grey_800"
android:textSize="14dp" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1.5"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#727272" />
<Button
android:id="#+id/apply"
android:layout_width="match_parent"
android:layout_height="35dp"
android:layout_marginBottom="10dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp"
android:background="#drawable/roundedcorneredittext"
android:text="APPLY"
android:textColor="#0277bd"
android:textSize="12dp" />
<Button
android:id="#+id/applied"
android:layout_width="match_parent"
android:layout_height="35dp"
android:layout_marginBottom="10dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp"
android:background="#drawable/roundedcorneredittext"
android:text="APPLIED"
android:textColor="#0277bd"
android:textSize="12dp"
android:visibility="invisible"
/>
</RelativeLayout>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.8">
<TextView
android:id="#+id/credittext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:textSize="12dp"
android:text="Credited To Jeb No." />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/credittext"
android:layout_toRightOf="#+id/credittext"
android:text="C100"
android:textSize="12dp"
/>
<TextView
android:id="#+id/amount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/credittext"
android:layout_marginRight="16dp"
android:text="Rs.100"
android:textSize="12dp"
/>
<TextView
android:id="#+id/pickdeal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/credittext"
android:layout_margin="5dp"
android:text="Haven't Picked Any Deals Yet"
android:textColor="#78909C"
android:textSize="12dp" />
<TextView
android:id="#+id/dealamount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#+id/amount"
android:text="Rs.50"
android:layout_marginRight="16dp"
android:layout_alignTop="#+id/pickdeal"
android:textSize="12dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/dealamount"
android:text="+"
android:layout_alignTop="#+id/dealamount"
android:layout_marginRight="2dp"
android:textSize="12dp"
/>
<TextView
android:id="#+id/discount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/pickdeal"
android:text="Discount"
android:layout_alignLeft="#+id/pickdeal"
android:textColor="#F44336"
android:textSize="12dp"
android:layout_marginTop="5dp"
/>
<TextView
android:id="#+id/discountedamount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="Rs.50"
android:textColor="#F44336"
android:layout_alignTop="#+id/discount"
android:layout_marginRight="16dp"
android:textSize="12dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/discountedamount"
android:layout_alignTop="#+id/discountedamount"
android:text="-"
android:textColor="#F44336"
android:layout_marginRight="2dp"
/>
</RelativeLayout>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1.5">
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#0277bd"
android:text="PROCEED TO PAY" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
recyelrview item
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="#+id/llContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:orientation="vertical"
android:padding="5dp">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="3dp"
card_view:cardBackgroundColor="#f9f9f9"
card_view:cardCornerRadius="1dp"
card_view:cardElevation="5dp">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:orientation="vertical"
android:weightSum="2"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
android:weightSum="2">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1.7">
<ImageView
android:id="#+id/icon"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:src="#drawable/nike" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:orientation="horizontal"
android:weightSum="2">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5">
<TextView
android:id="#+id/brandname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:text="hello"
android:textAllCaps="true"
android:textColor="#000000"
android:textSize="14dp"
android:typeface="sans" />
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/brandname"
android:layout_below="#+id/brandname"
android:layout_marginTop="10dp"
android:text="Get 50% off on Apparels"
android:textSize="12dp" />
<TextView
android:id="#+id/seemore"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#id/brandname"
android:layout_below="#+id/title"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:text="See More"
android:textSize="12dp" />
<ImageView
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_alignTop="#+id/seemore"
android:layout_marginLeft="10dp"
android:layout_toRightOf="#+id/seemore"
android:src="#drawable/sendgrey" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1.5">
<Button
android:id="#+id/free"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_centerInParent="true"
android:layout_marginBottom="16dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="16dp"
android:background="#drawable/roundedcorneredittext"
android:text="Free"
android:textColor="#0277bd"
android:textSize="12dp"
/>
<Button
android:id="#+id/taken"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_centerInParent="true"
android:layout_marginBottom="16dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="16dp"
android:background="#drawable/roundedcorner1"
android:text="Great!"
android:textColor="#ffffff"
android:textSize="12dp"
android:visibility="invisible"
/>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
Adapter.java
public class PromoCodeRecyclerViewAdapter extends RecyclerView.Adapter<PromoCodeRecyclerViewAdapter.MyViewholder> {
private ClickListener clickListener;
private LayoutInflater inflator;
private Context mcontext;
Typeface font;
public Button b1;
public ImageButton b2;
List<promocodedata> data = Collections.emptyList();
public PromoCodeRecyclerViewAdapter(Context context, List<promocodedata> y, Typeface font) {
inflator = LayoutInflater.from(context);
this.data = y;
this.mcontext = context;
this.font = font;
}
public void setClickListener(ClickListener clickListener) {
this.clickListener = clickListener;
}
#Override
public MyViewholder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = inflator.inflate(R.layout.promocode_item_layout, parent, false);
MyViewholder holder = new MyViewholder(view);
return holder;
}
#Override
public void onBindViewHolder(final MyViewholder holder, int position) {
promocodedata current = data.get(position);
holder.brandicon.setImageResource(current.brandicon);
holder.brandname.setText(current.brandname);
holder.title.setText(current.title);
holder.free.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
holder.taken.setVisibility(View.VISIBLE);
holder.free.setVisibility(View.INVISIBLE);
}
});
holder.taken.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
holder.taken.setVisibility(View.INVISIBLE);
holder.free.setVisibility(View.VISIBLE);
}
});
}
#Override
public int getItemCount() {
return data.size();
}
public interface ClickListener {
void itemClicked(View v, int position);
}
class MyViewholder extends RecyclerView.ViewHolder implements View.OnClickListener {
ImageView brandicon;
TextView brandname;
TextView title;
Button free;
Button taken;
public MyViewholder(View itemView) {
super(itemView);
itemView.setOnClickListener(this);
brandicon = (ImageView) itemView.findViewById(R.id.icon);
brandname = (TextView) itemView.findViewById(R.id.brandname);
title = (TextView) itemView.findViewById(R.id.title);
free = (Button)itemView.findViewById(R.id.free);
taken = (Button)itemView.findViewById(R.id.taken);
}
#Override
public void onClick(View v) {
if (clickListener != null) {
clickListener.itemClicked(v, getPosition());
}
}
}
}
You need to create your onitemclick because RecyclerView does not have a OnItemClick like Listview, i have an example in Github check it.