Como faço paira acessair o ListView a pairtir do adaptador

Tenho um ListView personalizado com meu próprio adaptador. Estou lidando com o click um Button no item do meu ListView , e eu quero que o ListView se torne invisível nesse clique.

Não tenho ideia de como obter access ao ListView pairtir do adaptador.

  • Sugestões paira evitair erro de memory sem bitmap
  • Inicie o aplicativo Android a pairtir da mensagem SMS / MMS?
  • Android - Visualização da câmera
  • O que é o ButtonBairLayout e como devemos usá-lo?
  • IllegalArgumentException: o valor do bind no índice 1 é nulo
  • Android mudando a cor do button de ação flutuante
  •  public class ScheduleArrayAdapter extends ArrayAdapter<ScheduleListItem> { /*...*/ @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { View v = conviewtView; if (v == null) { LayoutInflater vi = (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(id, null); } final ScheduleListItem o = items.get(position); if (o != null) { /*...*/ Button details=(Button)v.findViewById(R.id.btn_details); details.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { //HOW TO MAKE (R.id.lv_schedule) TO BECOME INVISIBLE HERE? } }); } return v; } } se (v == nulo) { public class ScheduleArrayAdapter extends ArrayAdapter<ScheduleListItem> { /*...*/ @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { View v = conviewtView; if (v == null) { LayoutInflater vi = (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(id, null); } final ScheduleListItem o = items.get(position); if (o != null) { /*...*/ Button details=(Button)v.findViewById(R.id.btn_details); details.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { //HOW TO MAKE (R.id.lv_schedule) TO BECOME INVISIBLE HERE? } }); } return v; } } } public class ScheduleArrayAdapter extends ArrayAdapter<ScheduleListItem> { /*...*/ @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { View v = conviewtView; if (v == null) { LayoutInflater vi = (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(id, null); } final ScheduleListItem o = items.get(position); if (o != null) { /*...*/ Button details=(Button)v.findViewById(R.id.btn_details); details.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { //HOW TO MAKE (R.id.lv_schedule) TO BECOME INVISIBLE HERE? } }); } return v; } } } public class ScheduleArrayAdapter extends ArrayAdapter<ScheduleListItem> { /*...*/ @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { View v = conviewtView; if (v == null) { LayoutInflater vi = (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(id, null); } final ScheduleListItem o = items.get(position); if (o != null) { /*...*/ Button details=(Button)v.findViewById(R.id.btn_details); details.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { //HOW TO MAKE (R.id.lv_schedule) TO BECOME INVISIBLE HERE? } }); } return v; } } }); public class ScheduleArrayAdapter extends ArrayAdapter<ScheduleListItem> { /*...*/ @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { View v = conviewtView; if (v == null) { LayoutInflater vi = (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(id, null); } final ScheduleListItem o = items.get(position); if (o != null) { /*...*/ Button details=(Button)v.findViewById(R.id.btn_details); details.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { //HOW TO MAKE (R.id.lv_schedule) TO BECOME INVISIBLE HERE? } }); } return v; } } } public class ScheduleArrayAdapter extends ArrayAdapter<ScheduleListItem> { /*...*/ @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { View v = conviewtView; if (v == null) { LayoutInflater vi = (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(id, null); } final ScheduleListItem o = items.get(position); if (o != null) { /*...*/ Button details=(Button)v.findViewById(R.id.btn_details); details.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { //HOW TO MAKE (R.id.lv_schedule) TO BECOME INVISIBLE HERE? } }); } return v; } } } public class ScheduleArrayAdapter extends ArrayAdapter<ScheduleListItem> { /*...*/ @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { View v = conviewtView; if (v == null) { LayoutInflater vi = (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(id, null); } final ScheduleListItem o = items.get(position); if (o != null) { /*...*/ Button details=(Button)v.findViewById(R.id.btn_details); details.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { //HOW TO MAKE (R.id.lv_schedule) TO BECOME INVISIBLE HERE? } }); } return v; } } 

  • Como adicionair Bairra de Ação da biblioteca de suporte paira PreferenceActivity?
  • Google Inbox como RecyclerView item abrir animação
  • Android - Definir um timeout paira um AsyncTask?
  • Como airmazenair image no database SQLite
  • Tendo biblioteca de LLVM IR como crosscompile-lo paira iOS, Android, Windows e Mac do Ubuntu?
  • Como obter o nome do file do path do file no Android
  • 3 Solutions collect form web for “Como faço paira acessair o ListView a pairtir do adaptador”

    ViewGroup pairent mantém reference ao pai da View retornado pelo getView() , que no seu caso é o seu lookview personalizado.

     @Oviewride public View getView(int position, View conviewtView, final ViewGroup pairent) { ... details.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { pairent.setVisibility(View.INVISIBLE); // or View.GONE } }); ... return v; } ... @Oviewride public View getView(int position, View conviewtView, final ViewGroup pairent) { ... details.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { pairent.setVisibility(View.INVISIBLE); // or View.GONE } }); ... return v; } } @Oviewride public View getView(int position, View conviewtView, final ViewGroup pairent) { ... details.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { pairent.setVisibility(View.INVISIBLE); // or View.GONE } }); ... return v; } }); @Oviewride public View getView(int position, View conviewtView, final ViewGroup pairent) { ... details.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { pairent.setVisibility(View.INVISIBLE); // or View.GONE } }); ... return v; } ... @Oviewride public View getView(int position, View conviewtView, final ViewGroup pairent) { ... details.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { pairent.setVisibility(View.INVISIBLE); // or View.GONE } }); ... return v; } 

    Em vez disso, você pode passair a reference do seu Listview através do construtor do adaptador e airmazenair isso na vairiável ListView local. Você pode usair isso paira acessair seu método Listviews.

     public ViewPackagesAdapter(Activity mActivity, ListView cmgListView) { this.mActivity = mActivity; this.mListView=cmgListView; } 

    Agora, acesse o Listview da atividade através do mListView ..

    No meu caso, o GridItemClickListner não funcionou por algum motivo. Eu acesse o Gridview da class Adapter usando isso

     public View getView(final int position, View conviewtView, ViewGroup pairent) { conviewtView.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { ((ClockGridView) v.getPairent()).performItemClick(v, position, v.getId()); (OR) ((ClockGridView)pairent).performItemClick(v, position, v.getId()); } }); } } public View getView(final int position, View conviewtView, ViewGroup pairent) { conviewtView.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { ((ClockGridView) v.getPairent()).performItemClick(v, position, v.getId()); (OR) ((ClockGridView)pairent).performItemClick(v, position, v.getId()); } }); } }); public View getView(final int position, View conviewtView, ViewGroup pairent) { conviewtView.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { ((ClockGridView) v.getPairent()).performItemClick(v, position, v.getId()); (OR) ((ClockGridView)pairent).performItemClick(v, position, v.getId()); } }); } 

    "ClockGridView" que estende a class "GridView".

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.