2015-07-13 1 views
2

Я нацелил элементы в панели действий с помощью ShowcaseView , но я не могу направить элементы ListView! Я пробовал это, и это не помогло:Как настроить элемент в ListView с помощью ShowcaseView в Android?

ShowcaseView sv = new ShowcaseView.Builder(this,true) 
         .setTarget(new ViewTarget(lv.getChildAt(1).findViewById(R.id.heart))) 
         // Here is where you supply the id of the action bar item you 
         // want to display 
         .setContentTitle("Heart") 
         .setContentText("Check the venues of your city") 
         .hideOnTouchOutside() 
         .build(); 

ответ

1

Очень простой. Возьмите элемент в свой ViewHolder, затем поместите код для отображения ShowCaseView внутри вашего bindView.

Не забудьте указать другой идентификатор для каждого элемента в списке.

Так что вы можете попробовать что-то вроде этого.

public class ViewHolder extends RecyclerView.ViewHolder { 

    private TextView button; 

    public ViewHolder(final View itemView) { 
    super(itemView); 
    button = (Button) itemView.findViewById(R.id.list_button); 

    button.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View v) { 
     new MaterialShowcaseView.Builder(getActivity()) 
      .setTarget(verifyButton) 
      .setDismissText("GOT IT") 
      .setContentText("Your text goes here") 
      .setDelay(100) // optional but starting animations immediately in onCreate can make them choppy 
      .singleUse(id + " define an unique id for each item of the list") // provide a unique ID used to ensure it is only shown once 
      .show(); 
     } 
     }); 
    } 
    } 
} 

Для получения дополнительной информации вы можете check the library here.