i edited my code to be compatible with yours
i write your code with modification to achieve what you want... i call InitialActivity yo yhe ListActivity and populate the list from a string array (populate them is not your problem) so, maybe the other things will help you...
package com.franco.test2;
import java.util.ArrayList;
import android.app.ListActivity;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
public class InitialActivity extends ListActivity {
// private List<Friend> friends; //lista de amigos
private ArrayList<String> usernames; //lista de usernames de amigos, para rellenar el listview
private String[] usernames_array;
private ActivityList listAdapter;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// setContentView(R.layout.main);
usernames_array = getResources().getStringArray(R.array.usernames);
actualizar();
}
public void actualizar()
{
//friends = con.RetrieveFriends(settings.getString("login",""));
// friends = MyApplication.getDatabaseAdapter().retrieveAllFriends();
// usernames.clear();
// for (int i=0;i<usernames.size();i++)
//for (int i=0;i<permissions.size();i++)
// {
// usernames.add(i,friends.get(i).getFullName());
//if (friends.get(i).getLastPosition()!=null)
// usernames.add(i,friends.get(i).getLastPosition().getpositiontimeFormated());
// }
usernames = new ArrayList<String>();
for(int i = 0 ; i < usernames_array.length ; i++){
usernames.add(usernames_array[i]);
}
listAdapter = new ActivityList(InitialActivity.this, android.R.id.text1, usernames);
// setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item3, usernames));
setListAdapter(listAdapter);
ListView lv = getListView();
lv.setTextFilterEnabled(true);
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
//startActivityForResult(i, 0);
}
});
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
Bundle bundle = new Bundle(); //bundle is like the letter
bundle.putString ("user", listAdapter.getItem(position)); //arg1 is the keyword of the txt, arg2 is the txt
// bundle.putString ("user", friends.get(position).getFullName()); //arg1 is the keyword of the txt, arg2 is the txt
// bundle.putString ("email", friends.get(position).getEmail());
// bundle.putString ("permission", friends.get(position).getPermission());
// Intent i=null;
// if (friends.get(position).getPermission().equals("total"))
// i = new Intent (AllActivity.this, Locate.class);
// else if (friends.get(position).getPermission().equals("perhours"))
// i = new Intent (AllActivity.this, LocatePerHours.class);
// else
// i = new Intent (AllActivity.this, LocatePerDays.class);
//
// i.putExtras(bundle);
// startActivity(i);
}
private OnClickListener callBtnListener = new OnClickListener(){
public void onClick(View v) {
Log.i("Info","Username: " + v.getTag());
}};
class ActivityList extends ArrayAdapter<String>{
public ActivityList(Context context, int textViewResourceId, ArrayList<String> objects) {
super(context, textViewResourceId, objects);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if(convertView == null){
LayoutInflater inflater = LayoutInflater.from(InitialActivity.this);
convertView = inflater.inflate(R.layout.new_list_item2, parent, false);
holder = new ViewHolder();
holder.text = (TextView)convertView.findViewById(R.id.friendName);
holder.button = (Button)convertView.findViewById(R.id.callButton);
convertView.setTag(holder);
}else{
holder = (ViewHolder) convertView.getTag();
}
holder.text.setText(getItem(position));
holder.button.setOnClickListener(callBtnListener);
holder.button.setTag( getItem(position) );
return convertView;
}
}
static class ViewHolder{
TextView text;
Button button;
}
}
i also deleted the last line (onClick) and add an onClickListener on the list activity.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/friendName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:padding="10dp"
android:textSize="16sp"/>
<Button
android:id="@+id/callButton"
android:layout_alignBaseline="@id/friendName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Call"
android:width="100px"
android:layout_alignParentRight="true"/>
</RelativeLayout>
i tested in my device and works, i delete the DataHolder class.
The other things like the Bundle map, Intent, is commented because i think is not your problem.
cheers.