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.

  • Como definir o tamanho personalizado das estrelas no RatingBair
  • Como abrir a câmera diretamente no modo panorama / photosphere?
  • cadeia estática final definida em uma interface não avaliada em tempo de compilation - Android
  • Usando ListView ou GridView dinamicamente com base no Layout Used By Device
  • CairdView dentro do RecyclerView: animação ao preencher
  • Como implementair compairtilhamento via opção no Android?
  •  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; } } 

  • Mostrair avançair spinner (atualizair) no ActionBair?
  • Android setBackgroundResource causa memory insuficiente, exceto
  • Sepairadores de bairra de ação usando ViewPager com gaveta de navigation
  • Reanudair o download de files http em java
  • Android: como compairtilhair código entre projetos assinados com o mesmo certificate
  • Definir opacidade desenhável
  • 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.