我不得不做类似的事情,但确实需要一名治疗者。 在此,我结束了对我的项目的工作。 它以显示无限进展的直径为.。
private class AsyncPop extends AsyncTask<Dialog, Integer, ScrollView>
{
@Override
protected void onPostExecute( ScrollView result )
{
setContentView( result );
super.onPostExecute( result );
}
@Override
protected ScrollView doInBackground( Dialog... params )
{
Dialog d = params[0];
Connection con = StaticDBHelper.getCon( TabActivityDetail.this.getParent() );
Statement st = null;
List<Timestamp> date = new ArrayList<Timestamp>();
List<String> text = new ArrayList<String>();
try
{
st = con.createStatement();
String sql = "select activityDateTime, detailText from xfu_ActivityDetail order by activityDateTime desc";
st.execute( sql );
ResultSet rs = st.getResultSet();
while( rs.next() )
{
date.add( rs.getTimestamp( "activityDateTime" ) );
text.add( rs.getString( "detailText" ) );
}
rs.close();
}
catch( SQLException e )
{
//Can t do a whole lot about it right now, should log
}
finally
{
if( null != st )
{
try
{
st.close();
}
catch( SQLException e )
{
//Just ignore it, should log
}
}
}
//Formatting
ViewGroup.LayoutParams textBoxp1 = new ViewGroup.LayoutParams( 130, ViewGroup.LayoutParams.WRAP_CONTENT );
ViewGroup.LayoutParams textBoxp2 = new ViewGroup.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT );
TableRow.LayoutParams rowp1 = new TableRow.LayoutParams( 130, TableRow.LayoutParams.WRAP_CONTENT );
TableRow.LayoutParams rowp2 = new TableRow.LayoutParams( TableRow.LayoutParams.FILL_PARENT,
TableRow.LayoutParams.WRAP_CONTENT );
TableLayout.LayoutParams table1 = new TableLayout.LayoutParams( TableLayout.LayoutParams.FILL_PARENT,
TableLayout.LayoutParams.FILL_PARENT );
TableLayout tableView = new TableLayout( _context );
tableView.setLayoutParams( table1 );
if( date.size() == 0 )
{
TextView dateView = new TextView( _context );
dateView.setText( "No activity details availible for given filter" );
dateView.setTypeface( Typeface.DEFAULT, Typeface.BOLD );
TableRow row = new TableRow( _context );
row.setLayoutParams( new LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT ) );
row.addView( dateView );
tableView.addView( row, new TableLayout.LayoutParams( LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT ) );
}
else
{
for( int index = -1; index < date.size(); index++ )
{
TableRow row = new TableRow( _context );
TextView dateView = new TextView( _context );
TextView textView = new TextView( _context );
if( index == -1 )
{
dateView.setText( "Date / Time" );
textView.setText( "Detail Text" );
dateView.setTypeface( Typeface.DEFAULT, Typeface.BOLD );
textView.setTypeface( Typeface.DEFAULT, Typeface.BOLD );
}
else
{
dateView.setText( LoaderV5._fm.format( date.get( index ) ) );
textView.setText( text.get( index ) );
}
dateView.setLayoutParams( textBoxp1 );
textView.setLayoutParams( textBoxp2 );
row.setLayoutParams( rowp2 );
row.addView( dateView, rowp1 );
row.addView( textView, rowp2 );
tableView.addView( row, table1 );
}
}
//tableView.setColumnShrinkable( 1, true );
HorizontalScrollView otherscroller = new HorizontalScrollView( _context );
otherscroller.addView( tableView );
ScrollView scroller = new ScrollView( _context );
scroller.addView( otherscroller );
scroller.setHorizontalScrollBarEnabled( true );
d.dismiss();
return scroller;
}
}