I want to display array items in listview but when I used simple array then it works properly and when I create array using loop it does not working. here is my code

```
public class MainActivity extends Activity {
String nm;
int number=0;
int ttl;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    TextView tv=(TextView) findViewById(R.id.textView1);
    ListView listView = (ListView) findViewById(R.id.list);
    //String[] values =new String[]{"val1","val2"};
ContentResolver cr=getContentResolver();    
 Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI,
         null, null, null, null);
 ttl=cur.getCount()+1;
    String[] myString = new String[ttl];

    List<String> values = new ArrayList<String>();

    if (cur.getCount() > 0) {
        while (cur.moveToNext()) {
            String id = cur.getString(
                        cur.getColumnIndex(ContactsContract.Contacts._ID));
        String name = cur.getString(
                        cur.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
        if (Integer.parseInt(cur.getString(cur.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER))) > 0) {
            //Query phone here.  Covered next
           nm=nm + name;
          number++;
  //   myString[number] = "image" + number;
    values.add(myString[number]);
        }
            }
    }

String[] myString1 = new String[12];
    for (int number1 = 0; number1 <= 11; number1++) {

        myString1[number1] = "image1" + number1;
    }

      ArrayAdapter<String> adapter=new ArrayAdapter<String>   (this,android.R.layout.simple_list_item_1,android.R.id.text1,values) ;
listView.setAdapter(adapter);

        }

```