如何在oncreate方法之前创建默认屏幕

时间:2014-01-12 05:29:15

标签: android

嘿,我正在创建一个非常沉重的应用程序...它工作正常但是当我从一个活动移动到另一个活动然后一个完全黑屏停留一段时间然后活动加载..现在我想制作默认屏幕,显示活动加载前的加载消息。另外用户认为应用程序挂起或崩溃...

public class TenderViewActivity extends ListActivity {

int[] pos={1,2,3,4,5,6,7,8,9};
public static DefaultHttpClient client;
private static final String DEFAULT = "N/A";
public final static String EXTRA_MESSAGE = "com.mobile.bidnemo.MESSAGE";
public final static String EXTRA_MESSAGE2 = "com.mobile.bidnemo.MESSAGE2";
JSONArray jArray;
ArrayList<Spanned> list = new ArrayList<Spanned>();  
int starting_point=0;
int limit=50;
String cat;
String tender_name;
String title;

@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
getWindow().setBackgroundDrawableResource(R.drawable.bid_backgrounds);
Toast.makeText(getApplicationContext(), "Please wait..", Toast.LENGTH_LONG).show();
Intent intent = getIntent();
cat = intent.getStringExtra(BidActivity.EXTRA_MESSAGE4);
tender_name = intent.getStringExtra(BidActivity.EXTRA_MESSAGE3);
title=intent.getStringExtra(BidActivity.EXTRA_MESSAGE5);
setTitle(title);

ArrayList<Spanned> tenders=tenderlist(cat,tender_name);
setListAdapter(new ArrayAdapter<Spanned>(this,R.layout.tender_listing,R.id.basic_details,tenders));
}

@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
String resid=returnid(pos[position]);
Intent detailsTender=new Intent(this,DetailsTenderActivity.class);
detailsTender.putExtra(EXTRA_MESSAGE2, resid);
startActivity(detailsTender);
Toast.makeText(this ,"You selected tender: "+resid, Toast.LENGTH_SHORT).show();
}



@SuppressLint("NewApi")
public ArrayList<Spanned> tenderlist(String cat, String name){
/***Tender view process begin***/
Spanned s;
String active="";
try {
StrictMode.enableDefaults();                    
JSONObject json = new JSONObject();
json.put("cat", cat);
json.put("srch_str", name);

client = new DefaultHttpClient();
String url = "https://www.myserver.com/index.php";
HttpPost request = new HttpPost(url);
request.setEntity(new ByteArrayEntity(json.toString().getBytes("UTF8")));
request.setHeader("json", json.toString());
HttpResponse response = client.execute(request);
HttpEntity entity = response.getEntity();
if (entity != null){
InputStream instream = entity.getContent();
String result="";
try{
 BufferedReader reader= new BufferedReader(new InputStreamReader(instream,"iso-8859-1"),8); 
StringBuilder sb=new StringBuilder();
String line=null;
while((line=reader.readLine())!=null){
sb.append(line+"\n");
}
instream.close();
result= sb.toString();
}catch(Exception e){}
jArray= new JSONArray(result);
for(int i=0; i<jArray.length();i++)
{
JSONObject getjson=jArray.getJSONObject(i);

String tender_id=getjson.getString("tender_id");
String tender_title=getjson.getString("tender_title");
String start_date=getjson.getString("tender_additional_info_bid_sub_start_date");
String end_date=getjson.getString("tender_additional_info_bid_sub_end_date");

SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
java.util.Date date= df.parse(end_date);     

Calendar c = Calendar.getInstance();
java.util.Date current_date=(c.getTime());

if(current_date.compareTo(date)<=0){ active="active"; }else{ active="inactive"; }

if("active".equals(active)){ 
s=Html.fromHtml(                "&nbsp;<br><font color='#232322'> ID: </font>"          +tender_id+
                            "&nbsp;<br><font color='#232322'> Title: </font>"       +tender_title+
                            "&nbsp;<br><font color='#232322'> Posting date: </font>"+start_date+
                            "&nbsp;<br><font color='#232322'> Ending date: </font>" +end_date+
                            "&nbsp;<br><font color='#25C31F'>"                      +active+ 
                            "</font><br>"); 
                }else{
                s=Html.fromHtml(
                            "&nbsp;<br><font color='#232322'> ID: </font>"          +tender_id+
                            "&nbsp;<br><font color='#232322'> Title: </font>"       +tender_title+
                            "&nbsp;<br><font color='#232322'> Posting date: </font>"+start_date+
                            "&nbsp;<br><font color='#232322'> Ending date: </font>" +end_date+
                            "&nbsp;<br><font color='#FF0000'>"                      +active+
                            "</font><br>");     
}
list.add(s);

}}    
}catch (Throwable t) {}
return list;
/***Tender view  process end***/
}

/**returnid function for toast message****/
public String returnid(int posVal){
String  p = null;
try{
JSONObject getjson=jArray.getJSONObject(posVal);
p=getjson.getString("tender_id");
}
catch(Exception e){}
return p;
}

我会做什么..请帮助..

0 个答案:

没有答案