hello . i am trying to make an android's UI programmatically.
Part 1 :
indeed at the first step i get the data from web server and save it in array . the first step works very well and it doesn't have any problem .
here this is the code of first step :
protected String doInBackground(String...Urls){
String Data="";
HttpURLConnection urlConnection = null;
try{
URL myUrl=new URL("http://10.0.2.2:80/Urgence/Default.aspx?type="+Type);
urlConnection = (HttpURLConnection)myUrl.openConnection();
BufferedReader in = new BufferedReader (new InputStreamReader(urlConnection.getInputStream()));
String temp="";
while((temp=in.readLine())!=null)
{
Data=Data+temp;
}
}
catch(Exception ex){
Log.d("Er>doInBackground", ex.toString());
urlConnection.disconnect();
}
finally{
urlConnection.disconnect();
}
return Data;
}
protected void onPostExecute(String Data){
try{
serverResponsesArray=Data.split("/",3);
makeItems(serverResponsesArray);
dialog.cancel();
}
catch(Exception ex){
Log.d("Er>onPostExecute",ex.toString());
}
finally{
dialog.cancel();
}
}
part 2 :
in second step i want to make an UI and show my data in some Rows !
if you notice to my code you can realize that i use a TextView to show array's members(subject,writer,main text,Date) . at first i use TextView for showing (Date,writer and subject) and after that i use it to show the main text . now it shows Date , Time and writer but it doesn't show the main text ! amazingly it increases the row's height but i cant see any main text ! i have debugged my code 3 times but it didnt have any problem !! now do me a favor and tell me what is the exact problem in my code ?! thanks in advance
code of second part :
public void makeItems(String Data[]){
int marginHorizontal=(int)getResources().getDimension(R.dimen.lpll_marginhor);
int marginVertical=(int)getResources().getDimension(R.dimen.lpll_marginver);
int txtMargin=(int)getResources().getDimension(R.dimen.lptvmargin);
Typeface face=Typeface.createFromAsset(getAssets(),"Font/ADOBEARABIC-REGULAR.OTF");
LayoutParams lpll;
LinearLayout llm=(LinearLayout)findViewById(R.id.contentMainLLayout);
LinearLayout llc;
TextView tv;
LayoutParams lptv;
String separateDataArray[]=new String[4];
try{
for(int i=0;i<=2;i++){
separateDataArray=Data[i].split("-",4);
llc=new LinearLayout(this);
llc.setOrientation(LinearLayout.HORIZONTAL);
lpll= new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT);
lpll.setMargins(marginVertical,marginHorizontal,marginVertical,marginHorizontal);
llc.setLayoutParams(lpll);
if(i%2==0){
llc.setBackgroundColor(getResources().getColor(R.color.bcfbc8));
}
else{
llc.setBackgroundColor(getResources().getColor(R.color.bcd1fb));
}
lptv=new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT);
lptv.setMargins(txtMargin,txtMargin,txtMargin,txtMargin);
tv=new TextView(this);
tv.setTypeface(face);
tv.setTextSize(getResources().getDimension(R.dimen.content_item_txtsize));
tv.setText(" موضوع : "+separateDataArray[0]+"\n"+" نویسنده : "+separateDataArray[2]+"\n"+" تاریخ : "+separateDataArray[1]);
tv.setLayoutParams(lptv);
llc.addView(tv);
tv=new TextView(this);
tv.setTypeface(face);
tv.setTextSize(getResources().getDimension(R.dimen.content_item_txtsize));
tv.setGravity(Gravity.CENTER);
tv.setText(separateDataArray[3]);
tv.setLayoutParams(lptv);
llc.addView(tv);
llm.addView(llc);
}
}
catch(Exception ex){
Log.d("Er>makeItems",ex.toString());
}
}