我有一个带有这样的自定义适配器的 listView
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
View view = convertView;
ViewHolder viewHolder = new ViewHolder();
if (convertView == null)
{
view = inflator.inflate(R.layout.question_adapter_layout, parent, false);
viewHolder.moreLayout = (LinearLayout) view.findViewById(R.id.extraOptions);
viewHolder.reportBtn = (Button) view.findViewById(R.id.more_report);
viewHolder.twitterBtn = (Button) view.findViewById(R.id.more_twitter);
viewHolder.googleBtn = (Button) view.findViewById(R.id.more_google);
viewHolder.fbBtn = (Button) view.findViewById(R.id.more_fb);
viewHolder.deleteBtn = (Button) view.findViewById(R.id.more_delete);
view.setTag(viewHolder);
}
else
viewHolder = (ViewHolder) view.getTag();
viewHolder.moreBtn.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
Utilities.vibrate(mContext);
if (viewHolder.moreLayout.getVisibility() == View.GONE)
viewHolder.moreLayout.setVisibility(View.VISIBLE);
else
viewHolder.moreLayout.setVisibility(View.GONE);
}
});
现在更改 onClickListener 中的任何内容,即viewHolder.moreLayout.setVisibility(View.GONE);
我需要使 viewHolder 最终但我将无法做到viewHolder = (ViewHolder) view.getTag();
我该如何解决这个问题?