android - How to reach single row using ListAdapter? -


i want change background color of textview in single row of list. have no idea how can reach specific row.

my xml:

<linearlayout     xmlns:android="http://schemas.android.com/apk/res/android"     android:id="@+id/ll_noterows"     android:orientation="vertical"     android:layout_width="match_parent"     android:layout_height="match_parent">      <linearlayout         android:id="@+id/ll_noterow"         android:orientation="vertical"         android:layout_width="match_parent"         android:layout_height="match_parent">          <textview             android:id="@+id/text1"             android:layout_width="match_parent"             android:layout_height="35dp"             android:text="tytuł"             android:textsize="25dp" />          <textview             android:id="@+id/text3"             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:maxlines="3"             android:text="treść"             android:textcolor="#505050"             android:textsize="15dp" />          <textview             android:id="@+id/noterowcolor"             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:text="textview" />      </linearlayout>  </linearlayout> 

and function fill data:

public void filldata()     {         cursor notescursor = mdbhelper.fetchallnotes();         startmanagingcursor(notescursor);          // create array specify fields want display in list (only title)         string[] = new string[]{notesdbadapter.key_title, notesdbadapter.key_body, notesdbadapter.key_color};          // , array of fields want bind fields (in case text1)         int[] = new int[]{r.id.text1, r.id.text3, r.id.noterowcolor};          // create simple cursor adapter , set display         simplecursoradapter notes = new simplecursoradapter(this, r.layout.notes_row, notescursor, from, to);         setlistadapter(notes);     } 

it works fine, when try this:

linearlayout rl=(linearlayout)findviewbyid(r.id.ll_noterow);  mcolortext = (textview) findviewbyid(r.id.noterowcolor); string newcolor = mcolortext.gettext().tostring();  if(colortoset.equals("blady_morski"))     rl.setbackgroundcolor(getresources().getcolor(r.color.blady_morski)); 

app crashes.

you'll need subclass simplecursoradapter , override getview(). method called each row in list , can customizations there.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -