public class test extends ListActivity{
/** Called when the activity is first created. */
protected Dialog mSplashDialog;
private static final String[] country = { "Iceland", "India", "Indonesia","Iran", "Iraq", "Ireland", "Israel", "Italy", "Laos", "Latvia","Lebanon", "Lesotho ", "Liberia", "Libya", "Lithuania","Luxembourg" };
private static final String[] curr = { "ISK", "INR", "IDR", "IRR", "IQD","EUR", "ILS", "EUR", "LAK", "LVL", "LBP", "LSL ", "LRD", "LYD","LTL ", "EUR"};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MyStateSaver data = (MyStateSaver) getLastNonConfigurationInstance();
if (data != null) {
// Show splash screen if still loading
if (data.showSplashScreen) {
showSplashScreen();
}
setContentView(R.layout.main);
// Rebuild your UI with your saved state here
} else {
showSplashScreen();
setContentView(R.layout.main);
ListView l1 = (ListView) findViewById(R.id.list);
l1.setAdapter(new EfficientAdapter(this));
l1.setItemsCanFocus(true);
}
}
@Override
public Object onRetainNonConfigurationInstance() {
MyStateSaver data = new MyStateSaver();
// Save your important data here
if (mSplashDialog != null) {
data.showSplashScreen = true;
removeSplashScreen();
}
return data;
}
/**
* Removes the Dialog that displays the splash screen
*/
protected void removeSplashScreen() {
if (mSplashDialog != null) {
mSplashDialog.dismiss();
mSplashDialog = null;
}
}
/**
* Shows the splash screen over the full Activity
*/
protected void showSplashScreen() {
mSplashDialog = new Dialog(this, R.style.SplashScreen);
mSplashDialog.setContentView(R.layout.splashscreen);
mSplashDialog.setCancelable(false);
mSplashDialog.show();
// Set Runnable to remove splash screen just in case
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
removeSplashScreen();
}
}, 3000);
}
/**
* Simple class for storing important data across config changes
*/
private class MyStateSaver {
public boolean showSplashScreen = false;
// Your other important fields here
}
public static class EfficientAdapter extends BaseAdapter {
private LayoutInflater mInflater;
public EfficientAdapter(Context context) {
mInflater = LayoutInflater.from(context);
}
public int getCount() {
return country.length;
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.listview, null);
convertView.setClickable(true);
convertView.setFocusable(true);
holder = new ViewHolder();
holder.text = (TextView) convertView.findViewById(R.id.TextView01);
holder.text2 = (TextView) convertView.findViewById(R.id.TextView02);
holder.text3 = (TextView) convertView.findViewById(R.id.TextView03);
holder.text4 = (TextView) convertView.findViewById(R.id.TextView04);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.text.setText(curr[position]);
holder.text2.setText(country[position]);
holder.text3.setText(country[position]);
holder.text4.setText(country[position]);
return convertView;
}
static class ViewHolder {
TextView text4;
TextView text;
TextView text2;
TextView text3;
}
}
public void onClick(View v) {
Toast.makeText(getApplicationContext(), "Zipcode: ", Toast.LENGTH_SHORT).show();
}
};
0
A
답변
0
yuo가 ListActivity에서 확장되고 있으면 목록에 android : id = "@ android : id/list"를 추가해야합니다 레이아웃이 같은
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<ListView android:id="@android:id/list" android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
내가 틀릴 수도 있지만 LogCat 추적 및 레이아웃을 제공하면 나는 당신에게 더 나은 조언을 줄 수 있습니다.
+0
이것이 문제 일 수도 있습니다. – dmon
0
나는 당신이 내용 없음을 설정하기 전에 대화 상자를 표시하려고 생각
이 줄 setContentView(R.layout.main)
를 작성하십시오; before showSplashScreen()
관련 문제
- 1. MPMoviePlayer가 장치에서 충돌하지만 시뮬레이터에서 정상적으로 작동합니다.
- 2. PHP 스크립트가 실패 할 때 계속 작동합니다.
- 3. Internet Explorer 8에서 submit 할 때 webapp에 대한 로그인 양식이 잘 작동합니다. Firefox에서 정상적으로 작동합니다.
- 4. 주 프로그램에서 개체가 충돌하지만 장치로 이동할 때
- 5. "애니메이션"이 "예"로 설정된보기 컨트롤러를 밀 때 iOS 앱이 충돌하지만 "애니메이션"이 "아니요"로 설정된 경우 잘 작동합니다.
- 6. jar 파일이 충돌하지만 netbeans 프로젝트가 작동합니다.
- 7. 웹 사이트는 dev 모드에서 작동합니다. IIS에 배포 할 때 내 ASP.NET 웹 사이트 개발/디버그 모드에서 잘 작동
- 8. 통화 버튼이 작동 할 때 입력
- 9. 새 활동이 시작될 때 이전 활동이 어두워지지 않음
- 10. 10.7에서 충돌하지만 10.6에서 작동 함 가능한 메모리 문제
- 11. 이 아주 잘 작동
- 12. 파이어 폭스에서 잘 작동
- 13. Android : 다른 활동이 시작될 때 감지 (또는 내 활동이 포커스를 잃을 때)
- 14. 활동이 열려있을 때 Spinner 값을 업데이트 하시겠습니까?
- 15. 블루투스를 통해 파일을 수신했을 때 활동이 발생했습니다
- 16. "startActivityForResult"에 의해 시작된 활동이 데이터를 반환 할 때 충돌합니다.
- 17. $ _FILES 배열은 PHP에서 .zip을 업로드 할 때 비어 있습니다. .jpg는 잘 작동합니다.
- 18. Red Hat에서 컴파일 할 때 세분화 오류가 발생하지만 우분투에서 잘 작동합니다.
- 19. AsyncTask가 데이터베이스를 사용할 때 활동이 닫힙니다.
- 20. 활동이 시작될 때 TextView에 포커스를 설정하는 방법?
- 21. android에서 활동이 시작될 때 softkeyboad를 숨기는 방법?
- 22. "계정 추가"활동이 완료되었을 때 알림을받는 방법
- 23. pyopengl 디스플레이가 동시에 소켓 서버로 작동 할 때 차단되었습니다.
- 24. 아래로 위로 스크롤 할 때 Iphone-cellForRowAtIndexPath가 이상하게 작동합니다.
- 25. 안드로이드 반복 알람이 잘 작동
- 26. 파이썬 :이 코드는 잘 작동
- 27. 내가 잘 작동 코드가 jQuery를
- 28. Google지도 API는 잘 작동 사파리
- 29. modalView가 회전 할 때 iPad의 UISplitViewController가 잘 회전하지 않았습니다.
- 30. 장고 매김 - 그것은 잘 작동 - 무제한 쿼리
여기에서 신고하려면 오류를 찾으십시오. –
당신은 무엇이 잘못되고 무엇이 잘못되었는지에 대해 훨씬 더 구체적 일 필요가 있습니다. Logcat은 좋은 시작 (일식 화면의 오른쪽 상단)입니다. –