I have an SQLite Database in my application with fieldname,fieldtype columns. fieldname consists of EditText namimg ...ex: etsearch,etsave,etcancel etc.. fieldtype is EditText.
I add fieldname values dynamically. I need to declare these EditTexts in my java class, as i'am creating my layout using java code.
I created an arraylist and added the fieldname values into it. I am confused how to declare the EditTexts using for loop.
My code :
public class MainActivity extends Activity
{
LinearLayout ll;
LinearLayout llgrower;
Cursor cursor;
ArrayList<String> edittexts;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
ll = new LinearLayout(this);
llgrower= new LinearLayout(this);
ll.addView(llgrower);
this.setContentView(ll);
cursor = DataBase.getdata("query to get fieldname,fieldtype");
try
{
if (cursor.moveToFirst())
{
do
{
edittexts.add(cursor.getString(0));
} while (cursor.moveToNext());
}
}
catch (Exception e) {}
for (int i=0;i<edittexts.size();i++)
{
}
}
}