2 개의 탭이있는 TabHost 활동이 있습니다. 또한 내 응용 프로그램에는 기본적으로 두 가지 유형의 알림이 있습니다. 이제 알림 1을 클릭하고 탭 2를 클릭하고 알림 2를 클릭하여 탭 1을 열려고합니다. 따라서 알림 ID에 탭의 ID를 나타내는 알림 인 텐트를 추가합니다. 탭을 변경하려면 getHttent(). getExtra (...)를 사용하여 TabHost 활동의 onResume 메소드에서 ID를 가져 와서 Tab을 변경하려고했습니다. 이 솔루션은 대부분의 경우에 사용할 수 있습니다. 그러나 때로는 제대로 작동하지 않지만, 나는 이유를 모른다. 그것이 때때로 작동하고 때로는 그렇지 않은 이유에 대한 단서가 있습니까? 아니면이 문제를 해결하기위한 더 나은 해결책이 있습니까?알림의 의도와 함께 탭을 변경합니다.
1
A
답변
0
이렇게하려면 ActivityGroups를 사용해야합니다.
http://ericharlow.blogspot.com/2010/09/experience-multiple-android-activities.html
그러나, 액티비티 그룹은 ICS에서 사용되지 않습니다 점에 유의하십시오. 탭에서활동 : 쉬운 방법은
Intent i = new Intent(v.getContext(), SearchList.class);
i.putExtra("search", search);
View view = SearchActivityGroup.group.getLocalActivityManager()
.startActivity("SearchList", i
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
.getDecorView();
// Again, replace the view
SearchActivityGroup.group.replaceView(view);
ActivityGroup:
package nl.dante.SuperDeals;
import java.util.ArrayList;
import android.app.ActivityGroup;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
public class SearchActivityGroup extends ActivityGroup {
View rootView;
// Keep this in a static variable to make it accessible for all the nested
// activities, lets them manipulate the view
public static SearchActivityGroup group;
// Need to keep track of the history if you want the back-button to work
// properly, don't use this if your activities requires a lot of memory.
private ArrayList<View> history;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/*
* this.history = new ArrayList<View>(); group = this;
*
* // Start the root activity within the group and get its view View
* view = getLocalActivityManager().startActivity("Search", new
* Intent(this,Search.class) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
* .getDecorView();
*
* // Replace the view of this ActivityGroup replaceView(view);
*/
}
@Override
protected void onResume() {
super.onResume();
this.history = new ArrayList<View>();
group = this;
// Start the root activity within the group and get its view
View view = getLocalActivityManager().startActivity("Search", new Intent(this, Search.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)).getDecorView();
// Replace the view of this ActivityGroup
replaceView(view);
}
public void replaceView(View v) {
// Adds the old one to history
if (history.size() == 0) {
if (rootView != null) {
history.add(rootView);
rootView = null;
}
}
history.add(v);
// Changes this Groups View to the new View.
setContentView(v);
}
public void back() {
try {
if (history.size() > 0) {
if (history.size() == 1) {
rootView = history.get(0);
Toasts.ToastImageView(this, "Druk nogmaals BACK om af te sluiten", R.drawable.power_64_off, "red");
}
history.remove(history.size() - 1);
setContentView(history.get(history.size() - 1));
} else {
finish();
}
if (history.size() < 3) {
// Tabhost.bannerImage2.setImageResource(0);
Tabhost.banner.setBackgroundResource(R.drawable.gradient_blue);
}
if (history.size() == 2) {
Tabhost.bannerImage1.setImageResource(R.drawable.sorteer_btn);
}
} catch (Exception ex) {
}
}
public int getHistorySize() {
return history.size();
}
@Override
public void onBackPressed() {
try {
SearchActivityGroup.group.back();
} catch (Exception ex) {
}
return;
}
}
관련 문제
- 1. android는 의도와 함께 작동합니다.
- 2. 안드로이드 - 의도와 함께 텍스트를 전달
- 3. 의도와 함께 실행기 페이지로 돌아가는 방법은 무엇입니까?
- 4. 의도와 함께 지불이 최종 사용자 청구서에 표시됩니다
- 5. 의도와 함께 활동 변경이 작동하지 않습니다.
- 6. 주 이미지가 작동하지의 의도와 함께 보낼 :(
- 7. Android 디버거가 보내기 의도와 함께 연결되지 않습니까?
- 8. MonoDroid가 스 와이프를 사용하여 탭을 변경합니다.
- 9. 알림의 인 텐트 선택자
- 10. overridePendingTransition 의도와 다른 행동
- 11. 카메라의 의도와 함께 사진 촬영 인물 사진을 회전합니다. android
- 12. onCreate는 의도와 함께 탐색 할 때 항상 호출됩니다.
- 13. 바코드 스캐너 + Xamarin 안드로이드 애플 리케이션의 의도와 함께 사용
- 14. 안드로이드 개발 : 의도와 함께 onClick 내부에 for 루프 작성하기
- 15. 값을 마샬링 할 수 없습니다 (의도와 함께 웹 뷰 시작)?
- 16. 안드로이드 의도와 MODE_PRIVATE
- 17. 의도와 동일한 GWT
- 18. 카메라의 의도와 활동/단편
- 19. 의도와 청취자의 차이점은 무엇입니까?
- 20. Android 7의 의도와 동등합니다. *
- 21. 는 의도와 다시 안드로이드
- 22. Android Lollipop - 알림의 파급 효과
- 23. 부트 스트랩 navbar가 데이터를 가져와 활성 탭을 변경합니다.
- 24. Vi : 파일의 마지막 n 열에서 탭을 쉼표로 변경합니다.
- 25. 루비와 함께 디렉토리의 파일 이름을 체계적으로 변경합니다.
- 26. htaccess를 하위 폴더의 CI와 함께 작동하도록 변경합니다.
- 27. 계류중인 의도와 용도는 무엇입니까? android
- 28. android에서 이메일 의도와 관련된 문제
- 29. cocos2d android의 의도와 관련된 문제
- 30. 각도 재료 의도와 구성 요소
이없는
이 내 ActivityGroup의 구현입니다? 왜 새로운 의도가 생기면 탭을 바꿀 수 없습니까? – antumin