您好我有这个列表视图,我想获取所选标题的名称(箭头指向的位置)我该怎么办?
视图代码
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
final ProgramacaoResult.Programa programa = getItem(position);
final ViewHolder holder;
if (convertView == null) {
convertView = LayoutInflater.from(getContext()).inflate(R.layout.item_programa_list, null);
holder = new ViewHolder();
holder.textViewHorario = (TextView) convertView.findViewById(R.id.textview_programa_horario);
holder.textViewTitle = (TextView) convertView.findViewById(R.id.textview_programa_title);
holder.switchNotificacao = (Switch) convertView.findViewById(R.id.switch_notificacao);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.textViewHorario.setText(programa.getHora());
holder.textViewTitle.setText(programa.getPrograma());
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getContext());
if (sharedPref.getBoolean(programa.getPrograma() + programa.getHora() , false)) {
//switch on
holder.switchNotificacao.setChecked(true);
} else {
//switch off
holder.switchNotificacao.setChecked(false);
}
convertView.setEnabled(false);
holder.switchNotificacao.setTag(position);
return convertView;
}