I have my own Adapter
for a listView
and a header. I want to choose which columns of listview
to hide; it works for list view in my adapter with textViewIdBaseDatos.setVisibility(View.GONE)
but I can't do that in the header. I could do in header.xml
with android:visibility="gone"
in the textView
that I want to hide, but I want to chose what columns want show/hide as preferences.
You can see the header and listView
in the screen:
header.xml
:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/fondoAccent">
<TextView
android:id="@+id/editTextIdBaseDatos"
android:layout_width="20dp"
android:layout_height="wrap_content"
android:layout_weight="0"
android:maxLength="2"
android:text="@string/idbasedatos"
android:textColor="@color/headlineList"
android:textSize="@dimen/testSizeHeadList"
android:background="@color/fondoAccent2"/>
<TextView
android:id="@+id/editTextPriority"
android:layout_width="20dp"
android:layout_height="wrap_content"
android:layout_weight="0"
android:maxLength="1"
android:text="@string/priority"
android:textColor="@color/headlineList"
android:textSize="@dimen/testSizeHeadList"
android:background="@color/fondoAccent2"/>
<TextView
android:id="@+id/editTextTarea"
android:layout_width="115dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLength="7"
android:text="@string/task"
android:textSize="@dimen/testSizeHeadList"
android:textColor="@color/headlineList"
android:background="@color/fondoAccent2"/>
A part of fragment that show the header and listView
:
Adapter = new MyAdapter(getActivity(), R.id.listView, idBaseDatos, name, description, start, startime, finished, duration, priority); // enlazamos el adaptador que hemos creado en clase java myAdapter con nuestra vista
listView.setAdapter(myAdapter);
listView.addHeaderView(headerView); // añade la cabecera a la listView
A part of myAdapter
:
public class MyAdapter extends BaseAdapter {
// 3 variables
private Context context;
private int layout;
private List<String> priority;
private List<String> nameTask;
private List<String> description;
private List<String> start;
private List<String> startime;
private List<String> idBasedatos;
private List<Integer> finished;
private List<String> duration;
// private int colorFinished = 0xFF00FF00 ;
private int colorFinished;
// constructor que recoge el contexto, el layout y los nombres
public MyAdapter(Context context, int layout,List<String> idBasedatos, List<String> nameTask, List<String> description, List<String> start, List<String> startime, List<Integer> finished , List<String> duration, List<String> priority){
this.context = context;
this.priority = priority;
this.layout = layout;
this.nameTask = nameTask;
this.description = description;
this.start = start; // date
this.startime = startime; // time in 24 H format
this.duration = duration;
this.idBasedatos = idBasedatos;
this.finished = finished; // Integer que hay que pasar a booleano
colorFinished = ContextCompat.getColor(context, R.color.colorPrimarySoft);