0
public class Great_listviewActivity extends Activity {
EditText edittext;
ListView listview;
Button search;

String[] text = { "One", "Two", "Three", "Four", "Five", "Six", "Seven",
                                                "Eight", "Nine", "Ten" };

int[] image = { R.drawable.icon, R.drawable.icon, R.drawable.icon,
                                R.drawable.icon, R.drawable.icon, R.drawable.icon, R.drawable.icon,
                                R.drawable.icon, R.drawable.icon, R.drawable.icon };
int textlength = 0;

ArrayList<String> text_sort = new ArrayList<String>();
ArrayList<Integer> image_sort = new ArrayList<Integer>();


/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    search = (Button) findViewById(R.id.Button01);

    edittext = (EditText) findViewById(R.id.EditText01);
    listview = (ListView) findViewById(R.id.ListView01);

   listview.setAdapter((ListAdapter) new MyCustomAdapter(text, image));



    search.setOnClickListener(new OnClickListener()
    {

    public void onClick(View v)
    {

    textlength = edittext.getText().length();
    text_sort.clear();
    image_sort.clear();

   for (int i = 0; i < text.length; i++)
    {
     if (textlength <= text[i].length())
       {
        if (edittext.getText().toString().equalsIgnoreCase((String) text[i].subSequence(0, textlength)))
         {
         text_sort.add(text[i]);
       image_sort.add(image[i]);   }                            }
      }   //end of for loop

      listview.setAdapter(new MyCustomAdapter(text_sort, image_sort));
    }   //end of onClick
    });   //end of search click


                    }


class MyCustomAdapter extends BaseAdapter implements ListAdapter
{

String[] data_text;
int[] data_image;

MyCustomAdapter()
{

}

MyCustomAdapter(String[] text, int[] image)
{
data_text = text;
data_image = image;
}

MyCustomAdapter(ArrayList<String> text, ArrayList<Integer> image)
{
data_text = new String[text.size()];
data_image = new int[image.size()];

for (int i = 0; i < text.size(); i++) {
    data_text[i] = text.get(i);
    data_image[i] = image.get(i);
  }

  }

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

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

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

 public View getView(int position, View convertView, ViewGroup parent)
{

LayoutInflater inflater = getLayoutInflater();
View row;

row = inflater.inflate(R.layout.listview, parent, false);

TextView textview = (TextView) row.findViewById(R.id.TextView01);
ImageView imageview = (ImageView) row.findViewById(R.id.ImageView01);

 textview.setText(data_text[position]);
imageview.setImageResource(data_image[position]);
return (row);
}

It got tripped up at the line listview.setAdapter((ListAdapter) new MyCustomAdapter(text, image)); It just says Source Not found. It leaves no clue of what could be wrong.

user370305
  • 108,599
  • 23
  • 164
  • 151
lilzz
  • 5,243
  • 14
  • 59
  • 87

2 Answers2

0

It just says Source Not found

This could've given you a clue to search for that message on this site. Please have a look at the answer to this question, it may help you to figure out what's going on.

Community
  • 1
  • 1
Amos M. Carpenter
  • 4,848
  • 4
  • 42
  • 72
0

have you checked whether the correct java compiler is attached to the Eclipse Environment.

medampudi
  • 399
  • 3
  • 15