Q:

DIsplay first letter of string to another textview in Android

I am displaying a listview in which, the row item has two textview.  The second textview is for the name of companies and the first textview is for the starting letter of the companies.  How this can be achieved ?  Need help !! 

public class ExampleAdapter extends BaseAdapter {

Context context;
ArrayList<ExamplePojo> items = new ArrayList<>();

public ExampleAdapter(Context context, ArrayList<ExamplePojo> items) {
    this.context = context;
    this.items = items;
}

@Override
public int getCount() {
    return items.size();
}

@Override
public Object getItem(int position) {
    return items.get(position);
}

@Override
public long getItemId(int position) {
    return items.indexOf(items.get(position));
}

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

    ViewHolder holder = null;
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context. LAYOUT_INFLATER_SERVICE);

    if (convertView == null){
        convertView = inflater.inflate(R.layout.example_row_item, null);
        holder = new ViewHolder();
        holder.txtSentence = (TextView) convertView.findViewById(R.id.txtSentence);
        holder.txtInitialLetter = (TextView) convertView.findViewById(R.id.txtInitialLetter);
        convertView.setTag(holder);
    }
    else {
        holder = (ViewHolder) convertView.getTag();
    }

    final ExamplePojo pojo = items.get(position);
    holder.txtSentence.setText(pojo.getSentence());
    holder.txtInitialLetter.setText(pojo.getSentence().charAt(0));
    return convertView;
}

public class ViewHolder{

    TextView txtSentence, txtInitialLetter;

}

}

A:

Here is code for showing first character in first textview and complete name in other textview. Also put below lines in if(convertView== null) block
final ExamplePojo pojo = items.get(position);
holder.txtSentence.setText(pojo.getSentence());
holder.txtInitialLetter.setText(pojo.getSentence().substring(0, 1));

