現在、私は私を狂ったように動かす問題があります。基本的に私は、カードのリストを表示するrecyclerviewを持っています。問題は私のアプリを走らせるたびにカードが表示されないことです。私はすでに私のサイズをチェックして、それは正しいです。私はカードビューはRecyclerViewで膨らんでいません
card_list.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_margin="8dp"
android:gravity="center_horizontal"
android:padding="25dp"
card_view:cardBackgroundColor="@color/cardview_light_background"
card_view:cardCornerRadius="4dp"
card_view:cardElevation="4dp"
card_view:cardUseCompatPadding="true">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.constraint.Guideline
android:id="@+id/guideline_horizontal_top"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_begin="103dp"
tools:layout_editor_absoluteY="192dp"
tools:layout_editor_absoluteX="8dp" />
<ImageView
android:id="@+id/offer_image"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:adjustViewBounds="true"
android:contentDescription=""
android:scaleType="centerCrop"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="ContentDescription"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintVertical_bias="0.0" />
<TextView
android:id="@+id/job_card_title"
style="@style/ShadowText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:text="Job Title"
android:textAlignment="center"
android:textColor="@color/black"
android:textSize="30sp"
android:textStyle="bold"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@+id/guideline_horizontal_top"
android:layout_marginTop="8dp"
app:layout_constraintHorizontal_bias="0.502"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp" />
<ImageView
android:id="@+id/right_image"
style="@style/ShadowText"
android:layout_width="130dp"
android:layout_height="40dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:src="@drawable/job_card_apply"
tools:ignore="ContentDescription"
android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="@+id/job_card_title"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toTopOf="@+id/job_card_company_name"
android:layout_marginRight="8dp"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginLeft="8dp"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp" />
<ImageView
android:id="@+id/left_image"
android:layout_width="130dp"
android:layout_height="40dp"
android:layout_alignTop="@+id/right_image"
android:layout_centerHorizontal="true"
android:layout_gravity="center_vertical"
android:src="@drawable/job_card_reject"
tools:ignore="ContentDescription"
android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="@+id/job_card_title"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toTopOf="@+id/job_card_company_name"
android:layout_marginLeft="8dp"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginRight="8dp"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp" />
<android.support.constraint.Guideline
android:id="@+id/guideline_horizontal_bottom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_begin="261dp"
tools:layout_editor_absoluteY="350dp"
tools:layout_editor_absoluteX="8dp" />
<TextView
android:id="@+id/job_card_company_name"
style="@style/ShadowText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:text="Company Name"
android:textAlignment="center"
android:textColor="@color/black"
android:textSize="28sp"
android:textStyle="bold"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toTopOf="@+id/guideline_horizontal_bottom"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp" />
<ImageView
android:id="@+id/job_card_image_location"
android:layout_width="28dp"
android:layout_height="28dp"
card_view:srcCompat="@drawable/ic_location_on_black"
android:layout_marginLeft="8dp"
app:layout_constraintLeft_toLeftOf="@+id/offer_image"
app:layout_constraintRight_toLeftOf="@+id/job_card_company_location"
app:layout_constraintHorizontal_bias="1.0"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toTopOf="@+id/guideline3"
android:layout_marginStart="8dp" />
<TextView
android:id="@+id/job_card_company_location"
style="@style/ShadowText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginBottom="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="11dp"
android:layout_toEndOf="@id/job_card_image_location"
android:text="Company Location"
android:textAlignment="center"
android:textColor="@color/black"
android:textSize="22sp"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="@+id/guideline3"
app:layout_constraintLeft_toLeftOf="@+id/job_card_image_location"
app:layout_constraintRight_toRightOf="@+id/offer_image"
app:layout_constraintTop_toTopOf="@+id/guideline_horizontal_bottom"
app:layout_constraintVertical_bias="0.0"
app:layout_constraintHorizontal_bias="0.21" />
<android.support.constraint.Guideline
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/guideline3"
app:layout_constraintGuide_begin="308dp"
android:orientation="horizontal"
tools:layout_editor_absoluteY="397dp"
tools:layout_editor_absoluteX="8dp" />
<ImageView
android:id="@+id/job_card_image_job_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_weight="1"
card_view:srcCompat="@drawable/ic_action_work"
app:layout_constraintRight_toLeftOf="@+id/job_card_job_type"
android:layout_marginRight="0dp"
android:layout_marginLeft="8dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintTop_toTopOf="@+id/guideline3"
android:layout_marginTop="8dp" />
<TextView
android:id="@+id/job_card_job_type"
style="@style/ShadowText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp"
android:layout_toEndOf="@id/job_card_image_job_type"
android:text="Job Type"
android:textAlignment="center"
android:textColor="@color/black"
android:textSize="22sp"
android:textStyle="bold"
app:layout_constraintTop_toTopOf="@+id/guideline3"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginBottom="8dp"
app:layout_constraintVertical_bias="0.014"
android:layout_marginRight="8dp"
app:layout_constraintRight_toRightOf="parent" />
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.CardView>
adapter.class
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
cardPosition = position - 2;
Log.d("Details Before : ","" + position);
if(v == null){
LayoutInflater inflater = LayoutInflater.from(context);
v = inflater.inflate(R.layout.card_list,parent,false);
}
randomImage.add(R.drawable.background_image_1);
randomImage.add(R.drawable.background_image_2);
randomImage.add(R.drawable.background_image_3);
randomImage.add(R.drawable.background_image_4);
randomImage.add(R.drawable.background_image_5);
randomImage.add(R.drawable.background_image_6);
randomImage.add(R.drawable.background_image_7);
randomImage.add(R.drawable.background_image_8);
Collections.shuffle(randomImage);
ImageView imageView = (ImageView) v.findViewById(R.id.offer_image);
//imageView.setImageResource(R.drawable.image_test);
//Picasso.with(context).load(R.drawable.job_card_background_1).transform(new BlurTransformation(context)).into(imageView);
Glide.with(context)
.load(randomImage.get(0))
.into(imageView);
TextView jobTitle = (TextView) v.findViewById(R.id.job_card_title);
TextView companyName = (TextView) v.findViewById(R.id.job_card_company_name);
TextView companyLocation = (TextView) v.findViewById(R.id.job_card_company_location);
TextView jobType = (TextView) v.findViewById(R.id.job_card_job_type);
ImageView imageLocation = (ImageView) v.findViewById(R.id.job_card_image_location);
ImageView imageJobType = (ImageView) v.findViewById(R.id.job_card_image_job_type);
jobTitle.setText(cardData.get(position).getJobTitle());
companyName.setText(cardData.get(position).getCompanyName());
/**
* If condition checking for data [company location]
*/
if((cardData.get(position).getCity().isEmpty() || cardData.get(position).getCity() == null) &&
(cardData.get(position).getState().isEmpty() || cardData.get(position).getState().equals("null"))){
companyLocation.setVisibility(View.INVISIBLE);
imageLocation.setVisibility(View.INVISIBLE);
}
else if((!cardData.get(position).getCity().isEmpty() || !cardData.get(position).getCity().equals("null")) &&
(cardData.get(position).getState() == null || cardData.get(position).getState().equals("null")))
companyLocation.setText(cardData.get(position).getCity());
else if((cardData.get(position).getCity().isEmpty() || cardData.get(position).getCity().equals("null")) &&
(!cardData.get(position).getState().isEmpty() || !cardData.get(position).getState().equals("null")))
companyLocation.setText(cardData.get(position).getState());
else
companyLocation.setText(cardData.get(position).getCity() + ", " + cardData.get(position).getState());
/**
* If condition checking for data [job type]
*/
if((cardData.get(position).getJobType().isEmpty() || cardData.get(position).getJobType().equals("null")) &&
(cardData.get(position).getJobPosition().isEmpty() || cardData.get(position).getJobPosition().equals("null"))){
jobType.setVisibility(View.INVISIBLE);
imageJobType.setVisibility(View.INVISIBLE);
}
else if((!cardData.get(position).getJobType().isEmpty() || !cardData.get(position).getJobType().equals("null")) &&
(cardData.get(position).getJobPosition().isEmpty() || cardData.get(position).getJobPosition().equals("null")))
jobType.setText(cardData.get(position).getJobPosition());
else if((cardData.get(position).getJobType().isEmpty() || cardData.get(position).getJobType().equals("null")) &&
(!cardData.get(position).getJobPosition().isEmpty() || !cardData.get(position).getJobPosition().equals("null")))
jobType.setText(cardData.get(position).getJobPosition());
else
jobType.setText(cardData.get(position).getJobType() + ", " + cardData.get(position).getJobPosition());
v.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.i("Layer type: ", Integer.toString(v.getLayerType()));
Log.i("Hardware Accel type:", Integer.toString(View.LAYER_TYPE_HARDWARE));
}
});
return v;
}
'RecyclerView'の' Adapter'クラスには 'getView()'メソッドがありません。 –
アダプターの設定方法は? –