我开发了这个应用程序,一切正常,但加载需要 4-5 秒,我不知道为什么,因为没有要加载的图像或互联网内容,只是 logcat 传播了大约 500 条关于垃圾收集器的消息。你能告诉我我做错了什么吗?这是一些代码:
public class HNappActivity extends SherlockFragmentActivity implements
HeadlinesFragment.OnHeadlineSelectedListener, CABNavLis{
HeadlinesFragment hnHeadlinesFragment;
int hnCatIndex = 0;
int hnArtIndex = 0;
Categories hnCurrentCat;
public String[] Rubriky = null;
int count;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_hnapp);
Rubriky = ((HNapp) this.getApplication()).getRubriky();
count=((HNapp) this.getApplication()).getCount();
hnHeadlinesFragment = (HeadlinesFragment) getSupportFragmentManager().findFragmentById(
R.id.headlines);
hnHeadlinesFragment.setOnHeadlineSelectedListener(this);
hnCatIndex = savedInstanceState == null ? 0 : savedInstanceState.getInt("catIndex", 0);
hnHeadlinesFragment.setSelectable(true);
restoreSelection(savedInstanceState);
}
void restoreSelection(Bundle savedInstanceState) {
if (savedInstanceState != null) {
setNewsCategory(savedInstanceState.getInt("catIndex", 0));
int artIndex = savedInstanceState.getInt("artIndex", 0);
hnHeadlinesFragment.setSelection(artIndex);
OnHeadlineSelected(artIndex);
}
}
活动_hnapp.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:id="@+id/headlines"
android:name="sk.ecopress.hn.android.HeadlinesFragment"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1.03" />
<RelativeLayout
android:id="@+id/relative_layout1"
android:layout_width="match_parent"
android:layout_height="40dp"
android:orientation="horizontal" >
<Button
android:id="@+id/titulka"
android:layout_width="40dp"
android:layout_height="40dp"
android:padding="0dp"
android:layout_alignParentLeft="true"
android:text="@string/titulka" />
<Button
android:id="@+id/sekcie"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_toRightOf="@id/titulka"
android:text="@string/sekcie"
android:padding="0dp" />
<Button
android:id="@+id/bookmarks"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_toRightOf="@id/sekcie"
android:text="@string/bookmarks"
android:padding="0dp" />
<Button
android:id="@+id/info"
android:layout_width="40dp"
android:layout_height="40dp"
android:padding="0dp"
android:layout_alignParentRight="true"
android:onClick="info"
android:text="@string/info" />
<Button
android:id="@+id/nastavenia"
android:layout_width="40dp"
android:layout_height="40dp"
android:padding="0dp"
android:layout_toLeftOf="@id/info"
android:onClick="settings"
android:text="@string/nastavenia" />
谢谢