小编kar*_*i j的帖子

如何在android中的sqlite中批量插入

我正在使用SQLiteOpenHelper进行数据插入.我需要插入2500个id和2500个名字,所以需要花费太多时间.请任何人帮我如何减少插入时间.我们可以一次插入多个记录吗?任何人帮助我.先感谢您.码:

public class DatabaseHandler extends SQLiteOpenHelper {
    SQLiteDatabase db;
    private static final int DATABASE_VERSION = 8;
    private static final String TABLE_CITY = "CITYDETAILS";
    public DatabaseHandler(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
        this.mContext = context;
}

public void onCreate(SQLiteDatabase db) {
    db.execSQL("DROP TABLE IF EXISTS " + TABLE_CITY );
    String CREATE_CITY_TABLE = "CREATE TABLE " + TABLE_CITY + "("
                + CityId + " INTEGER," + CityName + " TEXT " + ")";
    db.execSQL(CREATE_CITY_TABLE);
    db.execSQL(CREATE_RechargeTypes_TABLE);
    this.db=db;
 }

 @Override
 public void onUpgrade(SQLiteDatabase db, …
Run Code Online (Sandbox Code Playgroud)

sqlite android sqliteopenhelper

26
推荐指数
3
解决办法
2万
查看次数

如何在推送通知(Gcm)android中显示图像?

从两天开始,我试图这样做.但我失败了.请任何人建议我如何在推送通知中获取图像.先感谢您.

在此输入图像描述

编码我试过的:

@SuppressWarnings("deprecation")
private void handleMessage(Context mContext, Intent intent) {
    Bitmap remote_picture = null;
    long when = System.currentTimeMillis();
    int icon = R.drawable.reload_logo;
    try {
        Bundle gcmData = intent.getExtras();
        if(intent.getExtras().getString("message")!=null)
            Log.v("TAG_IMAGE", "" + intent.getExtras().getString("message"));
        Log.v("TAG_IMAGE", "" + intent.getExtras().getString("imageurl"));


        {
            NotificationCompat.BigPictureStyle notiStyle = new NotificationCompat.BigPictureStyle();
            notiStyle.setSummaryText(intent.getExtras().getString("message"));

            try {
                remote_picture = BitmapFactory.decodeStream((InputStream) new URL(intent.getExtras().getString("imageurl")).getContent());
            } catch (IOException e) {
                e.printStackTrace();
            }
            notiStyle.bigPicture(remote_picture);
            notificationManager = (NotificationManager) mContext
                    .getSystemService(Context.NOTIFICATION_SERVICE);
            PendingIntent contentIntent = null;

            Intent gotoIntent = new Intent();
            gotoIntent.setClassName(mContext, "com.reloadapp.reload.fragments.MainActivity");//Start activity when user taps on …
Run Code Online (Sandbox Code Playgroud)

android push-notification google-cloud-messaging

14
推荐指数
1
解决办法
2万
查看次数

如何根据android材料设计中的图像颜色更改工具栏和状态栏颜色的颜色?

我开始学习Android材料设计.我在棒棒糖版本中学到了一些新功能.今天我试图根据图像的颜色更改工具栏和状态栏的颜色.任何人都可以指导我或提供任何链接,如何做到这一点?

截图

例如,更改视图寻呼机选项卡时,状态栏和工具栏的颜色会发生变化.先感谢您. 截图

styles.xml:

   < style name="MyMaterialTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
            <item name="windowNoTitle">true</item>
            <item name="windowActionBar">false</item>
            <item name="colorPrimary">@color/colorPrimary</item>
            <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
            <item name="colorAccent">@color/colorAccent</item>
        </style>
Run Code Online (Sandbox Code Playgroud)

主要活动:

public class MainActivity extends AppCompatActivity implements FragmentDrawer.FragmentDrawerListener,FragmentDrawerRight.FragmentDrawerListener1 {

    private static String TAG = MainActivity.class.getSimpleName();


    private Toolbar mToolbar;
    ViewPager viewPager;
    TabLayout tabLayout;
    private FragmentDrawer drawerFragment;
    private FragmentDrawerRight  drawerFragmentRight;
    private ImageView pone,ptwo;
    DrawerLayout drawer_layout;
    int mutedColor;
    private CollapsingToolbarLayout collapsing_toolbar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        collapsing_toolbar  = (CollapsingToolbarLayout)findViewById(R.id.collapsing_toolbar);
        mToolbar = (Toolbar) findViewById(R.id.toolbar);

        setSupportActionBar(mToolbar);

        ptwo=(ImageView)mToolbar.findViewById(R.id.ptwo);


        drawerFragment = (FragmentDrawer)
                getSupportFragmentManager().findFragmentById(R.id.fragment_navigation_drawer);
        drawerFragmentRight = (FragmentDrawerRight) …
Run Code Online (Sandbox Code Playgroud)

android toolbar statusbar material-design android-5.0-lollipop

13
推荐指数
1
解决办法
6609
查看次数

扑扑的HTTP请求

我正在使用Android的Retrofit。通过基于REST的Web服务很容易检索和上传JSON。我们可以在Flutter中获得与Web服务的Retrofit等效的任何库吗?

android dart retrofit flutter

10
推荐指数
1
解决办法
1万
查看次数

如何在颤振中禁用手机回按

我是 Flutter 开发的新手。谁能分享我如何禁用后按flutter

在Android中,我们可以使用onbackpressed方法。

@Override
public void onBackPressed() {
  // super.onBackPressed(); commented this line in order to disable back press
  //Write your code here
  Toast.makeText(getApplicationContext(), "Back press disabled!", Toast.LENGTH_SHORT).show();
}
Run Code Online (Sandbox Code Playgroud)

flutter如何可能呢?

dart flutter

8
推荐指数
1
解决办法
6577
查看次数

如何在 dart 中解码令牌

任何人都可以解释如何使用 dart 解码 json 中的令牌。

我用下面的代码在android中完成了。但是如何在 dart 中解码令牌。

public class JWTUtils {

    public static String  decoded(String JWTEncoded) throws Exception {
        String encode = "";
        try {
            String[] split = JWTEncoded.split("\\.");
            Log.d("JWT_DECODED", "Header: " + getJson(split[0]));
            encode = getJson(split[1]);
        } catch (UnsupportedEncodingException e) {
            //Error
        }
        return encode;
    }

    private static String getJson(String strEncoded) throws UnsupportedEncodingException{
        byte[] decodedBytes = Base64.decode(strEncoded, Base64.URL_SAFE);
        return new String(decodedBytes, "UTF-8");
    }
}
Run Code Online (Sandbox Code Playgroud)

字符串编码数据 = JWTUtils.decoded(token);

dart flutter

5
推荐指数
1
解决办法
5134
查看次数

Android底部导航查看项目文本颜色?

我开始研究Android底部导航视图.但我面临一个问题.如果我向底部导航视图添加了5个项目,则只显示项目文本的选定项目.如果我添加3项,它工作正常.请告诉我如何显示所有5个项目的项目文本.先感谢您.

menu.xml文件:

<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context="com.reloadapp.reload.activity.IconTabsActivity">
    <item
        android:id="@+id/action_favorites"
        android:enabled="true"
        android:icon="@drawable/home_40"
        android:title="Home"
        app:showAsAction="ifRoom" />
    <item
        android:id="@+id/action_schedules"
        android:enabled="true"
        android:icon="@drawable/profile_40"
        android:title="Profile"
        app:showAsAction="ifRoom" />
    <item
        android:id="@+id/action_music"
        android:enabled="true"
        android:icon="@drawable/reload_40"
        android:title="Reload cash"
        app:showAsAction="ifRoom" />
    <item
        android:id="@+id/action_musi"
        android:enabled="true"
        android:icon="@drawable/notifications"
        android:title="Notifications"
        app:showAsAction="ifRoom" />
    <item
        android:id="@+id/action_mus"
        android:enabled="true"
        android:icon="@drawable/menu_40"
        android:title="More"
        app:showAsAction="ifRoom" />
</menu>
Run Code Online (Sandbox Code Playgroud)

依赖:编译'com.android.support:appcompat-v7:25.0.1'compile'c​​om.android.support:design:25.0.0'

 <android.support.design.widget.BottomNavigationView
        android:id="@+id/bottom_navigation"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:itemBackground="@color/textColorPrimary"
        app:menu="@menu/menu_icon_tabs"
        app:itemIconTint="@color/colorPrimary"
        app:itemTextColor="@color/colorPrimary"
        android:layout_alignParentBottom="true">
    </android.support.design.widget.BottomNavigationView>
Run Code Online (Sandbox Code Playgroud)

android android-menu android-support-library android-bottom-nav-view

4
推荐指数
1
解决办法
6386
查看次数

将枚举转换为列表&lt;String&gt;

我有枚举类,我想向 ListView 显示枚举数据。谁能告诉我该怎么做吗?

enum TableType { circle, square, rectangle }
Run Code Online (Sandbox Code Playgroud)

enums dart flutter

3
推荐指数
1
解决办法
4635
查看次数

颤振中onbackpressed的等效方法是什么

我希望在flutter应用程序中具有与Android相同的onbackpressed逻辑,并且我想在单击手机后退按钮时关闭该应用程序。

当我们单击电话返回而不是应用返回按钮时,谁能告诉我该怎么做。

android:

@Override
public void onBackPressed()
{
     // code here to show dialog
     super.onBackPressed();  // optional depending on your needs
}
Run Code Online (Sandbox Code Playgroud)

android dart flutter

2
推荐指数
2
解决办法
1779
查看次数

在Android中更改数据时,查看寻呼机的第一个和第二个片段数据是不是在更新?

我正在使用view pager(动态)来显示来自服务的数据.它工作正常但每当我再次调用服务时,视图寻呼机中的数据需要刷新和更新新数据(来自服务).

视图寻呼机中的所有片段都使用新数据进行刷新,但视图寻呼机的前两个片段未使用新数据进行更新,这两个片段(第一个和第二个)仅显示以前的数据.请任何人帮助我.

我的代码:

RechargeplansActivity.java:

public class RechargeplansActivity  extends FragmentActivity /*implements RechargePlansFragment.UserInterface*/ {
    static final String TAG = RechargeplansActivity.class.getSimpleName();
    SectionsPagerAdapter mSectionsPagerAdapter;
    ViewPager mViewPager;
    Intent intent;
    private ArrayList<String> mPlanNamesList;
    private ArrayList<BrowsePlan> mBrowsePlansList;
    TextView tx_network;
    Dialog message_dialg;
    Context context;
    String operatorid,circleid;

    Map<String, ArrayList<BrowsePlan>> mBrowsePlansMap;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_rechargeplans);

        context = this;

        intent = getIntent();
        setPlan_types(new ArrayList<String>());
        setBrowseplans(new ArrayList<BrowsePlan>());
        mBrowsePlansMap = new HashMap<String, ArrayList<BrowsePlan>>();
        //db = DatabaseHandler.getInstance(getApplicationContext());
        initUI();




        operatorid=intent.getStringExtra("op_id");
        circleid=intent.getStringExtra("cir_id");



        executeBrowsePlans();
        tx_network.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) …
Run Code Online (Sandbox Code Playgroud)

android dynamic android-viewpager fragmentpageradapter

1
推荐指数
1
解决办法
5763
查看次数

View.gone 在 Recyclerview android 中显示空白空间

我正在使用 recyclerview 来显示来自 Web 服务的数据。根据特定条件,我需要删除特定的回收者视图项。所以我正在使用 View.Gone。但它显示空白。我在谷歌上搜索了这个问题并将高度设置为 wrapcontent,但它不起作用。请任何人帮助我。

我的代码:xml:项目

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/businfo"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="wrap_content"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <android.support.v7.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:cardCornerRadius="4dp"
        app:contentPaddingBottom="10dp"
        app:contentPaddingTop="16dp"
        android:elevation="10dp"
        android:layout_margin="5dp"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true">
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:weightSum="2"
        android:orientation="horizontal">
        <TextView
            android:id="@+id/travel_name"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:textSize="14sp"
            android:layout_marginLeft="5dp"
            android:textColor="@color/holo_blue_light"
            android:text="CGR Travels"/>


        <TextView
            android:id="@+id/bus_price"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="right"
            android:textSize="14sp"
            android:textColor="#F04C3B"
            android:layout_marginRight="30dp"
            android:text="Rs.349"/>


    </LinearLayout>
    <View
        android:layout_width="match_parent"
        android:layout_height="0.5dp"
        android:layout_marginTop="5dp"
        android:background="#b6b6b6"/>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:weightSum="2"
        android:layout_marginTop="5dp"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/arrtime_desttime"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:layout_marginLeft="5dp"
            android:textSize="15sp"
            android:textColor="#1e356a"
            android:text="9.00P.M - 7.00AM"/> …
Run Code Online (Sandbox Code Playgroud)

android android-recyclerview

0
推荐指数
1
解决办法
3406
查看次数