0
I have a custom listview, with image and title, but I can not insert subtitle, see the codes:
Base Adapter
public class Adapterlistview extends Basedapter {
private LayoutInflater mInflater;
private ArrayList<Categoria> itens;
public AdapterListView(Context context, ArrayList<Categoria> itens) {
//Itens que preencheram o listview
this.itens = itens;
//responsavel por pegar o Layout do item.
mInflater = LayoutInflater.from(context);
}
/**
* Retorna a quantidade de itens
*
* @return
*/
public int getCount() {
return itens.size();
}
/**
* Retorna o item de acordo com a posicao dele na tela.
*
* @param position
* @return
*/
public Categoria getItem(int position) {
return itens.get(position);
}
/**
* Sem implementação
*
* @param position
* @return
*/
public long getItemId(int position) {
return position;
}
public View getView(int position, View view, ViewGroup parent) {
//Pega o item de acordo com a posção.
Categoria item = itens.get(position);
//infla o layout para podermos preencher os dados
view = mInflater.inflate(R.layout.item_list, null);
//atravez do layout pego pelo LayoutInflater, pegamos cada id relacionado
//ao item e definimos as informações.
((TextView) view.findViewById(R.id.text)).setText(item.getTexto());
((ImageView) view.findViewById(R.id.imagemview)).setImageResource(item.getIconeRid());
return view;
}
}
XML:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:padding="5sp">
<ImageView
android:id="@+id/imagemview"
android:layout_width="wrap_content"
android:layout_height="match_parent"
/>
<TextView
android:id="@+id/text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="20dp"
android:layout_marginLeft="5sp"
android:textStyle="bold"
android:gravity="center_vertical"
android:textColor="#FF000000"
/>
</LinearLayout>
How do I add a subitem, which stays in the same model, but below the title and smaller?
It worked out, thanks!
– War Lock