tenho um problema, encontrei um tutorial para criar uma ListView mas é implementado com extends Activity
e eu estou com extend Fragment
e por isso tenho um erro no local assinalado com uma seta:
package com.sapires.Joes;
import android.support.v4.app.Fragment;
import com.google.android.gms.internal.im;
import com.sapires.Pizza.R;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
import android.app.Activity;
import android.app.ListActivity;
import android.content.Context;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
public class Ementa extends Fragment {
Context cont;
String[] titulos;
String[] descricoes;
int[] images = { R.drawable.um, R.drawable.dois, R.drawable.tres,
R.drawable.quatro,R.drawable.cinco,R.drawable.seis };
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
View android = inflater.inflate(R.layout.ementa_2, container, false);
Resources res = getResources();
titulos = res.getStringArray(R.array.titulos);
descricoes = res.getStringArray(R.array.descricoes);
ListView list = (ListView) android.findViewById(R.id.listView1);
--> VivzAdapter adapter = new VivzAdapter(this, titulos, images, descricoes);
list.setAdapter(adapter);
return android;
}
}
class VivzAdapter extends ArrayAdapter<String> {
Context context;
int[] images;
String[] titleArray;
String[] descriptionArray;
VivzAdapter(Context c,String[] titulos, int imgs[], String[] desc) {
super(c, R.layout.ementa_2, R.id.textView1, titulos);
this.context = c;
this.images = imgs;
this.titleArray = titulos;
this.descriptionArray = desc;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View row = inflater.inflate(R.layout.ementa_2, parent, false);
ImageView myImage = (ImageView) row.findViewById(R.id.imageView);
TextView myTitle = (TextView) row.findViewById(R.id.textView1);
TextView myDescription = (TextView) row.findViewById(R.id.textView2);
myImage.setImageResource(images[position]);
myTitle.setText(titleArray[position]);
myDescription.setText(descriptionArray[position]);
return row;
}
}
o erro é: The constructor VivzAdapter(Ementa, String[], int[], String[]) is undefined
Mas alterando para extend Activity
funciona, podem ajudar?