Cant split String into array properly

coachoutletttl

New Member
So this is my activity....and my xml for that activity. What I am doing is getting a html file of a timetable..taking off the tag with regex and then putting it in my own table.The code appears to show in the table rows, however the info is only going into the top two rows. The first is the days of the week and the second is all the information from that day. What I want is for the information to be split into each row. Can anybody help?\[code\]public class MainActivity extends Activity {private TextView[][] megaTableOfAwesome = new TextView[9][6];EditText ID;Button Enter;TextView WORK;/** Called when the activity is first created. */@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); megaTableOfAwesome[0][0] = (TextView) findViewById(R.id.textView00);//Mon megaTableOfAwesome[0][1] = (TextView) findViewById(R.id.textView01);//tue megaTableOfAwesome[0][2] = (TextView) findViewById(R.id.textView02);//wed megaTableOfAwesome[0][3] = (TextView) findViewById(R.id.textView03);//thurs megaTableOfAwesome[0][4] = (TextView) findViewById(R.id.textView04);//friday megaTableOfAwesome[0][5] = (TextView) findViewById(R.id.textView05);//friday megaTableOfAwesome[1][0] = (TextView) findViewById(R.id.textView10);//all inside mon megaTableOfAwesome[1][1] = (TextView) findViewById(R.id.textView11);//all time tues megaTableOfAwesome[1][2] = (TextView) findViewById(R.id.textView12);//all inside wed megaTableOfAwesome[1][3] = (TextView) findViewById(R.id.textView13);//all inside thurs megaTableOfAwesome[1][4] = (TextView) findViewById(R.id.textView14);//all inside fri megaTableOfAwesome[1][5] = (TextView) findViewById(R.id.textView15);//all inside sat megaTableOfAwesome[2][0] = (TextView) findViewById(R.id.textView20); megaTableOfAwesome[2][1] = (TextView) findViewById(R.id.textView21); megaTableOfAwesome[2][2] = (TextView) findViewById(R.id.textView22); megaTableOfAwesome[2][3] = (TextView) findViewById(R.id.textView23); megaTableOfAwesome[2][4] = (TextView) findViewById(R.id.textView24); megaTableOfAwesome[2][5] = (TextView) findViewById(R.id.textView25); megaTableOfAwesome[3][0] = (TextView) findViewById(R.id.textView30); megaTableOfAwesome[3][1] = (TextView) findViewById(R.id.textView31); megaTableOfAwesome[3][2] = (TextView) findViewById(R.id.textView32); megaTableOfAwesome[3][3] = (TextView) findViewById(R.id.textView33); megaTableOfAwesome[3][4] = (TextView) findViewById(R.id.textView34); megaTableOfAwesome[3][5] = (TextView) findViewById(R.id.textView35); megaTableOfAwesome[4][0] = (TextView) findViewById(R.id.textView40); megaTableOfAwesome[4][1] = (TextView) findViewById(R.id.textView41); megaTableOfAwesome[4][2] = (TextView) findViewById(R.id.textView42); megaTableOfAwesome[4][3] = (TextView) findViewById(R.id.textView43); megaTableOfAwesome[4][4] = (TextView) findViewById(R.id.textView44); megaTableOfAwesome[4][5] = (TextView) findViewById(R.id.textView45); megaTableOfAwesome[5][0] = (TextView) findViewById(R.id.textView50); megaTableOfAwesome[5][1] = (TextView) findViewById(R.id.textView51); megaTableOfAwesome[5][2] = (TextView) findViewById(R.id.textView52); megaTableOfAwesome[5][3] = (TextView) findViewById(R.id.textView53); megaTableOfAwesome[5][4] = (TextView) findViewById(R.id.textView54); megaTableOfAwesome[5][5] = (TextView) findViewById(R.id.textView55); megaTableOfAwesome[6][0] = (TextView) findViewById(R.id.textView60); megaTableOfAwesome[6][1] = (TextView) findViewById(R.id.textView61); megaTableOfAwesome[6][2] = (TextView) findViewById(R.id.textView62); megaTableOfAwesome[6][3] = (TextView) findViewById(R.id.textView63); megaTableOfAwesome[6][4] = (TextView) findViewById(R.id.textView64); megaTableOfAwesome[6][5] = (TextView) findViewById(R.id.textView65); megaTableOfAwesome[7][0] = (TextView) findViewById(R.id.textView70); megaTableOfAwesome[7][1] = (TextView) findViewById(R.id.textView71); megaTableOfAwesome[7][2] = (TextView) findViewById(R.id.textView72); megaTableOfAwesome[7][3] = (TextView) findViewById(R.id.textView73); megaTableOfAwesome[7][4] = (TextView) findViewById(R.id.textView74); megaTableOfAwesome[7][5] = (TextView) findViewById(R.id.textView75); megaTableOfAwesome[8][0] = (TextView) findViewById(R.id.textView80); megaTableOfAwesome[8][1] = (TextView) findViewById(R.id.textView81); megaTableOfAwesome[8][2] = (TextView) findViewById(R.id.textView82); megaTableOfAwesome[8][3] = (TextView) findViewById(R.id.textView83); megaTableOfAwesome[8][4] = (TextView) findViewById(R.id.textView84); megaTableOfAwesome[8][5] = (TextView) findViewById(R.id.textView85); moo();}public void moo() {//setContentView(R.layout.real_main); //TextView text; //ID = (EditText) findViewById(R.id.ID); //Enter = (Button) findViewById(R.id.button); //Enter.setOnClickListener(this); //String idNum = ID.getText().toString(); //String URL = "http://www.timetable.ul.ie/tt2.asp?T1="; //String request = URL + idNum; //String HTML = "";*/ //String URL = "http://www.timetable.ul.ie/tt2.asp?T1="; //Student number is hard coded, change this //String request = URL + "11060212";Bundle extras = getIntent().getExtras(); String request; if(extras!=null){ request =getIntent().getExtras().getString(""); HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost(request); try { httpclient.execute(httppost);// setContentView(R.layout.activity_main); ResponseHandler<String> responseHandler = new BasicResponseHandler(); String ResponseBody = httpclient.execute(httppost, responseHandler); String table = ResponseBody.substring(ResponseBody .indexOf("<table border=\"1\" cellpadding=\"0\" width=\"100%\" cellspacing=\"0\">")); table = table.replaceAll("&nbsp;"," \n "); table = table.replaceAll("-"," "); table = table.replaceAll(","," \n"); table = table.replaceAll("No records returned","\n no \n records \n returned"); table = table.replaceAll(" "," \n"); table = table.substring(0, table.indexOf("</table>")); /** * x:9 y:6 */ String[][] tableRevamp = new String[9][6]; for (int i = 0; i < tableRevamp.length && table != null; i++) { for (int j = 0; j < tableRevamp.length && table != null; j++) { int start = table.indexOf("<td"); int end = table.indexOf("</td"); String holder = ""; if (start != -1 || end != -1) holder = table.substring(start, end + 5); if (i == 0) { while (holder.length() > 3) { if (holder.charAt(0) != '<') { tableRevamp[j] = holder.substring(0, holder.indexOf('<')).trim(); } holder = holder.substring(holder.indexOf('>') + 1); holder = holder.trim(); } } else { String[] classes = holder.split("<hr>"); String[] singleClass = new String[12]; for (int a = 0; a < classes.length; a++) { int b = 0; while (classes[a].length() > 3) { if (classes[a].trim().charAt(0) != '<') { singleClass = classes[a].substring(0, classes[a].indexOf('<')).trim(); b++; } classes[a] = classes[a].substring(classes[a] .indexOf('>') + 1); classes[a] = classes[a].trim(); } for (int c = 0; c < singleClass.length; c++) { if (singleClass[c] != null) tableRevamp[j] += singleClass[c] + " \n \n "; } } } if (table.length() > 4) table = table.substring(end + 5); else table = null; } } for (int i = 0; i < 9; i++) { for (int j = 0; j < 6; j++) { megaTableOfAwesome[j].setText(tableRevamp[j]); } } } catch (ClientProtocolException e) { Toast.makeText(getApplicationContext(), "fail 1", Toast.LENGTH_LONG).show(); } catch (IOException e) { Toast.makeText(getApplicationContext(), "fail 2", Toast.LENGTH_LONG).show(); }}}}\[/code\]XML:\[code\]<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="wrap_content"android:layout_height="wrap_content" ><FrameLayout android:id="@+id/scrollViewFrameLayout" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginBottom="30dip" > <ScrollView android:id="@+id/verticalScrollContainer" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingTop="10dip" > <HorizontalScrollView android:id="@+id/horizontalScrollContainer" android:layout_width="match_parent" android:layout_height="match_parent" > <TableLayout android:id="@+id/tableLayout1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#800080" > <TableRow android:id="@+id/tableRow0" android:layout_width="match_parent" android:layout_height="match_parent" > </TableRow> <TableRow android:id="@+id/tableRow1" android:layout_width="wrap_content" android:layout_height="wrap_content" > <TextView android:id="@+id/textView00" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" android:textColor="#FFFFFF" android:textSize="25dp" /> <TextView android:id="@+id/textView01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" android:textColor="#FFFFFF" android:textSize="25dp" /> <TextView android:id="@+id/textView02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" android:textColor="#FFFFFF" android:textSize="25dp" /> <TextView android:id="@+id/textView03" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#FFFFFF" android:textSize="25dp" /> <TextView android:id="@+id/textView04" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#FFFFFF" android:textSize="25dp" /> <TextView android:id="@+id/textView05" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#FFFFFF" android:textSize="25dp" /> </TableRow> <TableRow android:id="@+id/tableRow2" android:layout_width="wrap_content" android:layout_height="wrap_content" > <TextView android:id="@+id/textView10" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#FFFFFF" android:textSize="15dp" /> <TextView android:id="@+id/textView11" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#FFFFFF" android:textSize="15dp" /> <TextView android:id="@+id/textView12" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#FFFFFF" android:textSize="15dp" /> <TextView android:id="@+id/textView13" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#FFFFFF" android:textSize="15dp" /> <TextView android:id="@+id/textView14" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#FFFFFF" android:textSize="15dp" /> <TextView android:id="@+id/textView15" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#FFFFFF" android:textSize="15dp" /> </TableRow> <TableRow android:id="@+id/tableRow3" android:background= "#000000" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="15dp" > <TextView android:id="@+id/textView20" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#FFFFFF" android:textSize="15dp" /> <TextView android:id="@+id/textView21" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#FFFFFF" android:textSize="15dp" /> <TextView android:id="@+id/textView22" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#FFFFFF" android:textSize="15dp" /> <TextView android:id="@+id/textView23" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#FFFFFF" android:textSize="15dp" /> <TextView android:id="@+id/textView24" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#FFFFFF" android:textSize="15dp" /> <TextView android:id="@+id/textView25" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#FFFFFF" android:textSize="15dp" /> </TableRow> <TableRow android:id="@+id/tableRow4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#000000" android:textSize="15dp" > <TextView android:id="@+id/textView30" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#FFFFFF" android:textSize="15dp" /> <TextView android:id="@+id/textView31" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#FFFFFF" android:textSize="15dp" /> <TextView android:id="@+id/textView32" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#FFFFFF" android:textSize="15dp" /> <TextView android:id="@+id/textView33" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#FFFFFF" android:textSize="15dp" /> <TextView android:id="@+id/textView34" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:id="@+id/textView35" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#FFFFFF" android:textSize="15dp" /> </TableRow> <TableRow android:id="@+id/tableRow5" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#000000" android:textSize="15dp" > <TextView android:id="@+id/textView40" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:id="@+id/textView41" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#FFFFFF" android:textSize="15dp" /> <TextView android:id="@+id/textView42" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#FFFFFF" android:textSize="15dp" /> <TextView android:id="@+id/textView43" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#FFFFFF" android:textSize="15dp" /> <TextView android:id="@+id/textView44" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#FFFFFF" android:textSize="15dp" /> <TextView android:id="@+id/textView45" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#FFFFFF" android:textSize="15dp" /> </TableRow> <TableRow android:id="@+id/tableRow6" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#000000" > <TextView android:id="@+id/textView50" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="15dp" /> <TextView android:id="@+id/textView51" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:id="@+id/textView52" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:id="@+id/textView53" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:id="@+id/textView54" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:id="@+id/textView55" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </TableRow> <TableRow android:id="@+id/tableRow7" android:layout_width="wrap_content" android:layout_height="wrap_content" > <TextView android:id="@+id/textView60" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:id="@+id/textView61" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:id="@+id/textView62" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:id="@+id/textView63" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:id="@+id/textView64" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:id="@+id/textView65" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </TableRow> <TableRow android:id="@+id/tableRow8" android:layout_width="wrap_content" android:layout_height="wrap_content" > <TextView android:id="@+id/textView70" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:id="@+id/textView71" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:id="@+id/textView72" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:id="@+id/textView73" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:id="@+id/textView74" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:id="@+id/textView75" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </TableRow> <TableRow android:id="@+id/tableRow9" android:layout_width="wrap_content" android:layout_height="wrap_content" > <TextView android:id="@+id/textView80" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:id="@+id/textView81" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:id="@+id/textView82" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:id="@+id/textView83" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:id="@+id/textView84" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:id="@+id/textView85" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </TableRow> <EditText android:id="@+id/mon" android:layout_width="30dp" android:layout_height="50dp" android:layout_below="@+id/tableRow2" android:background="#FFFFFF" android:inputType="text" /> </TableLayout> </HorizontalScrollView> </ScrollView></FrameLayout>\[/code\]
 
Back
Top