以下是我的gridbuilder類正在啓動應用程序的mainactivity中使用。窗口已滿應用程序啓動時使用GridView
public class GridBuilderActivity extends BaseAdapter {
private Context mcontext;
private final String[] featurename;
private final int[] Imageid;
public GridBuilderActivity(Context context, String[] featurename, int[] Imageid) {
mcontext = context;
this.featurename = featurename;
this.Imageid = Imageid;
}
@Override
public int getCount() {
return Imageid.length;
}
@Override
public Object getItem(int position) {
return null;
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View grid;
LayoutInflater inflater = (LayoutInflater) mcontext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if (convertView == null) {
grid = new View(mcontext);
grid = inflater.inflate(R.layout.grid_layout, null);
TextView textView = (TextView) grid.findViewById(R.id.gridtextview);
ImageView imageView = (ImageView) grid.findViewById(R.id.gridimage);
textView.setText(featurename[position]);
imageView.setImageResource(Imageid[position]);
//Density wise text size fixing
float density = mcontext.getResources().getDisplayMetrics().density;
if (density >= 4.0) {
//System.out.println("Ex");
textView.setTextSize(15);
}
if (density >= 3.0) {
//System.out.println("hp");
textView.setTextSize(14);
}
if (density >= 2.0) {
//System.out.println("xhp");
textView.setTextSize(13);
}
if (density >= 1.5) {
//System.out.println("hpin");
textView.setTextSize(12);
}
if (density >= 1.0) {
// System.out.println("mp");
textView.setTextSize(11);
}
//Fixing finished here
} else {
grid = (View) convertView;
}
return grid;
}
}
在對應用程序啓動許多手機我m如果低於警告和電話保持後應用程序啓動幾秒鐘掛。
W/CursorWindow: Window is full: requested allocation 72 bytes, free space 40 bytes, window size 2097152 bytes
W/CursorWindow: Window is full: requested allocation 72 bytes, free space 40 bytes, window size 2097152 bytes
W/CursorWindow: Window is full: requested allocation 72 bytes, free space 40 bytes, window size 2097152 bytes
請幫助如何解決這個問題。這嚴重影響了應用程序的性能。我通過傳遞必要的參數來調用mainactivity。如下佈局
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:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/WhiteSmoke"
android:orientation="vertical">
<include
layout="@layout/stdtoolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/WhiteSmoke"
android:scrollbars="none">
<!--<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/WhiteSmoke">-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginTop="10dp"
android:orientation="vertical">
//1st row
//height 330
<GridView
android:id="@+id/grid"
android:layout_width="match_parent"
android:layout_height="420dp"
android:background="@color/White"
android:columnWidth="90dp"
android:gravity="center"
android:numColumns="3"
android:stretchMode="columnWidth"
android:verticalSpacing="10dp" />
//2nd row
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="@color/white"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:text="Entertainment" />
<HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:drawableTop="@mipmap/dailytemp"
android:padding="10dp"
android:text="Text1" />
<TextView
android:id="@+id/text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toEndOf="@+id/text1"
android:drawableTop="@mipmap/youtemp"
android:padding="10dp"
android:text="text2" />
</RelativeLayout>
</LinearLayout>
</HorizontalScrollView>
</LinearLayout>
//3rd row
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="@color/White"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:padding="5dp"
android:text="Care And Share "
android:textAlignment="center" />
<HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scrollbars="none">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal">
<TextView
android:id="@+id/appupdate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/support"
android:layout_gravity="center"
android:drawableTop="@drawable/update"
android:padding="15dp"
android:text="Update"
android:textAlignment="center" />
<TextView
android:id="@+id/usermanual"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/support"
android:layout_gravity="center"
android:layout_toEndOf="@+id/appupdate"
android:drawableTop="@drawable/manual"
android:padding="15dp"
android:text="Manual"
android:textAlignment="center" />
<TextView
android:id="@+id/support"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="2dp"
android:layout_toEndOf="@+id/usermanual"
android:drawableTop="@drawable/help"
android:padding="15dp"
android:text="Support"
android:textAlignment="center" />
<TextView
android:id="@+id/googleplaylike"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/support"
android:layout_gravity="center_horizontal"
android:layout_toEndOf="@+id/support"
android:drawableTop="@drawable/likeus"
android:padding="15dp"
android:text="@string/rate_google_play"
android:textAlignment="center" />
<TextView
android:id="@+id/shareus"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/support"
android:layout_gravity="center"
android:layout_toRightOf="@+id/googleplaylike"
android:drawableTop="@drawable/share"
android:padding="15dp"
android:text="Share"
android:textAlignment="center" />
<TextView
android:id="@+id/hireus"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/support"
android:layout_gravity="center"
android:layout_toEndOf="@+id/shareus"
android:drawableTop="@drawable/hireus"
android:padding="15dp"
android:text="Hire Us"
android:textAlignment="center" />
</RelativeLayout>
</LinearLayout>
</HorizontalScrollView>
</LinearLayout>
//3rd row
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="@color/White"
android:orientation="horizontal"
android:weightSum="1">
<android.support.design.widget.TextInputLayout
android:layout_width="240dp"
android:layout_height="wrap_content">
<EditText
android:id="@+id/quickfbet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:hint="@string/quick_feedback" />
</android.support.design.widget.TextInputLayout>
<TextView
android:id="@+id/feedbacksubmitbtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:drawableTop="@mipmap/submit"
android:text="Submit"
android:textAlignment="center" />
<!-- <TextView
android:id="@+id/hireus"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="0.5"
android:drawableTop="@mipmap/hire_us"
android:text="Hire Us"
android:textAlignment="center" />-->
</LinearLayout>
//4th row
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="@color/White"
android:orientation="horizontal">
<Button
android:id="@+id/ALS"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ALS"
android:visibility="gone" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:id="@+id/banner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/picformat" />
<ImageView
android:id="@+id/gif1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/picformat" />
<ImageView
android:id="@+id/click1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/picformat" />
<ImageView
android:id="@+id/image1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/picformat" />
<ImageView
android:id="@+id/gif2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/picformat" />
<ImageView
android:id="@+id/click2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/picformat" />
<ImageView
android:id="@+id/image2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/picformat" />
<ImageView
android:id="@+id/gif3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/picformat" />
<ImageView
android:id="@+id/click3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/picformat" />
<ImageView
android:id="@+id/image3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/picformat" />
<ImageView
android:id="@+id/gif4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/picformat" />
<ImageView
android:id="@+id/click4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/picformat" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
</LinearLayout>
logcat的。
E/ANR_LOG: Current msg <1> = { when=-19s830ms what=122 target=android.app.ActivityThread$H obj=BindServiceData{[email protected] intent=Intent { cmp=jss.smartapp/.ConnectionBasedTask }} }
E/ANR_LOG: Current msg <2> = { when=-19s830ms what=116 target=android.app.ActivityThread$H [email protected] }
E/ANR_LOG: Current msg <3> = { when=-19s824ms what=7 target=com.google.android.gms.common.internal.zzh arg2=-1 [email protected] }
E/ANR_LOG: Current msg <4> = { when=-19s231ms what=0 target=android.view.ViewRootImpl$ViewRootHandler callback=android.view.View$ScrollabilityCache }
E/ANR_LOG: Current msg <5> = { when=-19s231ms what=0 target=android.view.ViewRootImpl$ViewRootHandler callback=android.view.View$ScrollabilityCache }
E/ANR_LOG: Current msg <6> = { when=-15s804ms what=0 target=android.os.Handler callback=com.google.android.gms.internal.zzces }
E/ANR_LOG: Current msg <7> = { when=+59m38s136ms what=0 target=android.os.Handler callback=com.google.android.gms.internal.zzces }
你可以幫助基於此的東西。
嘗試在清單文件中添加此在標記中的android:largeHeap =「true」。 –
這已經添加 – Panache
圖片你正在加載的是創建加載的問題 –