获取列表视图标题名称

时间:2016-04-13 17:44:33

标签: java android

您好我有这个列表视图,我想获取所选标题的名称(箭头指向的位置)我该怎么办?

enter image description here

视图代码

@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;
}

0 个答案:

没有答案