Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/190.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 获取列表视图标题名称_Java_Android - Fatal编程技术网

Java 获取列表视图标题名称

Java 获取列表视图标题名称,java,android,Java,Android,您好,我有这个列表视图,我想获取所选标题的名称(箭头指向的位置),我该怎么做 视图的代码 @Override public View getView(final int position, View convertView, ViewGroup parent) { final ProgramacaoResult.Programa programa = getItem(position); final ViewHolder holder; if (convertView

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

视图的代码

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

向我们展示您的UI代码。您希望在java文件中从何处获取该数据?请指定位置。@bhunubaba我想在我发布的方法中获取它,然后在交换机的onClickListener上使用。您能输入您的XML代码吗?这不是您选择的选项卡名称吗?。。。尝试使用position find获取选项卡/标题名的android.support.design.widget.getSelectedTabPosition()。显示您的UI代码。您想在java文件中从何处获取该数据?请指定位置。@bhunubaba我想在我发布的方法中获取它,然后在交换机的onClickListener上使用。您能输入您的XML代码吗?这不是您选择的选项卡名称吗?。。。尝试使用position find获取选项卡/标题名称的android.support.design.widget.getSelectedTabPosition()。。