Android Studio erro na classe AdapterImage , não reconhecida

1. Android Studio erro na classe AdapterImage , não reconhecida

Marco Brainiac
mbrainiac

(usa Debian)

Enviado em 29/12/2016 - 17:39h

Pessoal estou com um problema

a classe ImageAdapter.java não é reconhecida na classe MainActivity.java, fica vermelha, único erro.
Sou iniciante no Android e estou emperrado


package com.example.brainiac.olalayoutemgrade;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.GridView;
import android.widget.ListAdapter;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

GridView gridview = (GridView) findViewById(R.id.gridview);
gridview.setAdapter(new ImageAdapter(this));

gridview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
String position = null;
Toast.makeText(
MainActivity.this, "" + position, Toast.LENGTH_SHORT).show();
}
});


}
}




import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;

import com.example.brainiac.olalayoutemgrade.R;

/**
* Created by brainiac on 29/12/16.
*/

public class ImageAdapter extends BaseAdapter {

private Context mContext;

public ImageAdapter(Context c) {
mContext = c;
}

public int getCount() {
return mThumbIds.length;
}

public Object getItem(int position) {
return null;
}

public long getItemId(int position) {
return 0;
}

public View getView(int position, View convertView, ViewGroup parent) {
ImageView imageView;
if (convertView == null) {
imageView = new ImageView(mContext);
imageView.setLayoutParams(new GridView.LayoutParams(85, 85));
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setPadding(8, 8, 8, 8);
} else {
imageView = (ImageView) convertView;
}

imageView.setImageResource(mThumbIds[position]);
return imageView;
}

private Integer[] mThumbIds = {
R.drawable.android_nerd, R.drawable.baby_android,
R.drawable.business_android, R.drawable.flame_android,
R.drawable.girl_android, R.drawable.ninja_android,
R.drawable.super_android, R.drawable.tablet_android,
R.drawable.ufo_android, R.drawable.walle_android
};
}






ActivityMain.xml

[code]
<?xml version="1.0" encoding="utf-8"?>
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/gridview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:columnWidth="90dp"
android:numColumns="auto_fit"
android:verticalSpacing="10dp"
android:horizontalSpacing="10dp"
android:stretchMode="columnWidth"
android:gravity="center" />



  






Patrocínio

Site hospedado pelo provedor RedeHost.
Linux banner
Linux banner
Linux banner

Destaques

Artigos

Dicas

Tópicos

Top 10 do mês

Scripts