Github:https://github.com/jjvang/AnimationDemo
我没有使用SQlite数据库,除非创建一个带有数据计数的公共类。我通过另一个有同样错误的问题阅读:SQLiteConnection databases leak when running emulator
03-17 04:36:01.301 7516-7526/? W/SQLiteConnectionPool: A SQLiteConnection object for database '+data+user+0+com_google_android_gms+databases+metrics_db' was leaked! Please fix your application to end transactions in progress properly and to close the database when it is no longer needed.
03-17 04:36:01.301 7516-7526/? W/SQLiteConnectionPool: A SQLiteConnection object for database '+data+user+0+com_google_android_gms+databases+help_responses_db_18' was leaked! Please fix your application to end transactions in progress properly and to close the database when it is no longer needed.
03-17 04:36:01.301 7516-7526/? W/SQLiteConnectionPool: A SQLiteConnection object for database '+data+user+0+com_google_android_gms+databases+auto_complete_suggestions_db' was leaked! Please fix your application to end transactions in progress properly and to close the database when it is no longer needed.
DataBase代码:
public class YourPojo {
static int [] imageResources = {R.drawable.capture1,R.drawable.capture2,R.drawable.capture3,R.drawable.capture4,R.drawable.capture5};
static String[] imageText = {"egas", "gasdg", "gasdga", "four", "five"};
static String[] imageDifferent = {"new", "new", "new", "new", "new"};
}
PagerAdapter:
public class customSwip extends PagerAdapter {
YourPojo yourPojo;
private int [] imageResourcess = yourPojo.imageResources;
private Context ctx;
private LayoutInflater layoutInflater;
public customSwip(Context c) {
ctx=c;
}
@Override
public int getCount() {
return imageResourcess.length;
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
layoutInflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View itemView=layoutInflater.inflate(R.layout.activity_custom_swip,container,false);
ImageView imageView=(ImageView) itemView.findViewById(R.id.swip_image_view);
TextView textHmong=(TextView) itemView.findViewById(R.id.different);
TextView textEnglish=(TextView) itemView.findViewById(R.id.english);
imageView.setImageResource(yourPojo.imageResources[position]);
final String dummytext = yourPojo.imageText[position];
textHmong.setText(yourPojo.imageDifferent[position]);
textEnglish.setText(yourPojo.imageText[position]);
container.addView(itemView);
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(ctx, "" + dummytext, Toast.LENGTH_SHORT).show();
}
});
return itemView;
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
}
@Override
public boolean isViewFromObject(View view, Object object) {
return (view==object);
}
}
MainActivity:
public class MainActivity extends AppCompatActivity {
YourPojo yourPojo;
ViewPager viewPager;
customSwip customSwip;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
viewPager=(ViewPager)findViewById(R.id.viewPager);
customSwip=new customSwip(this);
viewPager.setAdapter(customSwip);
Button button = (Button)findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// SOMEHOW PASS THESE DATA TO customSWIP to set new values
int [] imageResources2 ={R.drawable.capture2,R.drawable.capture2,R.drawable.capture5,R.drawable.capture2,R.drawable.capture2};
yourPojo.imageResources = imageResources2;
String[] imageText2 = {"new", "two", "three", "four", "five"};
yourPojo.imageText = imageText2;
String[] imageHmong2 = {"new", "new", "new", "new", "new"};
yourPojo.imageDifferent = imageHmong2;
viewPager.setAdapter(customSwip);
}
});
}
}
找到解决方案:打开设置 - 应用程序 - Google Play服务 - 管理空间 - 清除所有数据
我将解决方案读作上述声明,但我无法在设置中找到“APPS”部分。我甚至使用了没有出现的搜索功能。 SCREEN SHOOT HERE
请告知。
谢谢!