适配器的getView()方法未访问

时间:2018-10-05 13:43:43

标签: android adapter getview

这是我的适配器:

public GamblingVideoAdapter(Context context, ArrayList<GamblingVideosBean> gamblingVideosBeans) {
        this.context = context;
        this.gamblingVideosBeans = gamblingVideosBeans;
        Log.d("===GamblingVideoAdapter", "adaper text : " + gamblingVideosBeans.size());
    }

    @Override
    public int getCount() {
        return gamblingVideosBeans.size();
    }

    @Override
    public Object getItem(int position) {
        return gamblingVideosBeans.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Log.d("===gambling", "adapter hi kevin");

        return null;
    }  

这是我在logcat中得到的:

    10-05 19:09:20.118 5925-5925/com.sb.android.acg.test I/Ads: Scheduling ad refresh 60000 milliseconds from now.
10-05 19:09:20.386 5925-7768/com.sb.android.acg.test D/===GamblingVideoAdapter: adaper text : 50  

我尝试了Stackoverflow中给出的所有答案,但似乎没有一个能解决我的问题。

1 个答案:

答案 0 :(得分:0)

尝试一下

#include<stdio.h>

 int main(void)
 {
 // Constant and Variable Declarations
 const int MPH_SPEED_MIN = 1;
 const int MPH_SPEED_MAX = 100;
 const int HOURS_TRAVLED_MIN = 1;
 int mphSpeed = 1;
 int hoursEntered = 0;
 int distanceTraveled = 0;
 int counterNum = 0;
 int distanceNum = 0;
 char ch = 'y';



  // *** Input ***
  do {
    printf("What is the speed of the vehicle in MPH? ");
    scanf("%d", &mphSpeed);
    while ((mphSpeed < MPH_SPEED_MIN) || (mphSpeed > MPH_SPEED_MAX)) {
    printf("\tThe speed entered must be between %d and %d inclusive\n",MPH_SPEED_MIN, MPH_SPEED_MAX);
        printf("\tPlease re-enter the speed of the vehicle in MPH: ");
        scanf("%d", &mphSpeed);
    }

    printf("How many hours has it traveled? ");
    scanf("%d", &hoursEntered);

    while (hoursEntered < HOURS_TRAVLED_MIN) {
        printf("\tThe hours traveled must be a positive number.\n");
        printf("\tPlease re-enter the number of hours traveled: ");
        scanf("%d", &hoursEntered);
    }
    printf("\n");
    printf("Hour\tDistance Traveled\n");
    distanceTraveled = hoursEntered * mphSpeed;
    for (counterNum = 1; counterNum <= hoursEntered; counterNum++) {
        distanceNum = distanceTraveled * counterNum;
        printf("%d\t%d miles\n", counterNum, distanceNum);
    }
    printf("\n");
    printf("Run the program again (Y/N)? ");
    scanf(" %c", &ch);
    printf("\n");
} while (ch == 'Y' || ch == 'y');

  return 0;
}