小编CBe*_*4ok的帖子

使用一个查询MySQL插入多行

我想编写脚本,带有多个插入查询的函数.让我更好地解释一下.

我有一个quantityhtml格式的输入.我有MySQL查询插入registered user表中.所以我希望我的函数插入此次查询"数量"次.

 mysql_query("INSERT INTO `pxlot` (realname,email,address,phone,status,regtime,ip) 
 VALUES ('$realname','$email','$address','$phone','0','$dateTime','$ip')")
 or die (mysql_error()); // Inserts the user.
Run Code Online (Sandbox Code Playgroud)

例如插入3次.有什么建议?

php mysql

40
推荐指数
4
解决办法
14万
查看次数

有限项目的无限卷轴

我有一个GridView5x50内的物品.

我需要向所有方向滚动它们,而不是在到达终点时停止,只是从顶部/左侧开始.

例如从左到右滚动

在滚动之前

1 2 3 4 5
6 7 8 9 10
Run Code Online (Sandbox Code Playgroud)

滚动到右边后

5 1 2 3 4
10 6 7 8 9
Run Code Online (Sandbox Code Playgroud)

从上到下(或从下到上)

在滚动到底部之前

1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
Run Code Online (Sandbox Code Playgroud)

滚动后

6 7 8 9 10
11 12 13 14 15
1 2 3 4 5
Run Code Online (Sandbox Code Playgroud)

我试着让它像GridView原生卷轴一样平滑滚动.

android android-layout android-gridview android-canvas android-view

16
推荐指数
3
解决办法
922
查看次数

Android ViewModel内部服务(替代)

我有一个服务,提供大多数时间用户可见的UI.

当我遇到问题时,我正在尝试新的应用程序架构.

MyModelviewModel viewModel = ViewModelProviders.of(this).get(MyModelviewModel.class);

但正如你所知,this只能AppCompatFragment

还有其他选择吗?或者我可以将观察者直接放在我LiveData喜欢的东西上ViewModel

viewModel.getList().observe(Playground.this, new Observer<List<TestEntity>>() {
    @Override
    public void onChanged(@Nullable List<TestEntity> items) {
        recyclerViewAdapter.addItems(items);
    }
});
Run Code Online (Sandbox Code Playgroud)

android mvvm android-livedata android-viewmodel

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

滚动到折叠视图而不使用工具栏

我正在制作类似于最近android的状态栏的布局.

在此输入图像描述

我有两个Views内部容器.ViewPagerRecyclerView.默认行为应该是当我滚动时RecyclerView,我想ViewPager减小尺寸,反之亦然.

在此输入图像描述

逻辑:

viewPagerMaxHeight = 200;
if scrollTop
  is ViewPager.height > viewPagerMaxHeight?
    YES: Prevent Scroll and Decrease ViewPager size apropriatry
    No: Scroll RecyclerView
if scrollBottom
  did we scroll to position 0?
    YES: Start increasing ViewPager size
    No: Scroll RecyclerView
Run Code Online (Sandbox Code Playgroud)

几个注意事项: - RecyclerView包含各种尺寸的物品. - 有时会删除和添加项目 - 这是一个简单的RecyclerView,而不是在通知中它们相互折叠.

我可以自己构建大部分逻辑但是我无法做出适当的监听器RecyclerView,它将返回滚动的方向和数量.防止RecyclerView滚动是一个奖励

编辑:

我在github上做了一个例子

v.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
    @Override
    public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, …
Run Code Online (Sandbox Code Playgroud)

android android-recyclerview nestedscrollview android-nestedscrollview

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

关于运行新应用程序的Android动画

我正在为自己创造新的发射器.现在,当我从我的主要活动中运行应用程序时,它有这个默认动画,它将我的启动器放在后面并在其上弹出新应用程序.而不是这个,我想附加我自己的动画.最好我想默认从触摸点显示的素材动画.

到目前为止我尝试过的事情:

您需要在Android上使用此活动的Theme.AppCompat主题(或后代)

http://tips.androidhive.info/2015/09/android-how-to-apply-material-design-theme/

 <style name="swLaunch" parent="swLaunch.Base">
    <item name="android:windowContentTransitions">true</item>
    <item name="android:windowAllowEnterTransitionOverlap">true</item>
    <item name="android:windowAllowReturnTransitionOverlap">true</item>
    <item name="android:windowSharedElementEnterTransition">@android:transition/explode</item>
    <item name="android:windowSharedElementExitTransition">@android:transition/explode</item>
    <item name="android:windowEnterAnimation">@android:transition/explode</item>
    <item name="android:windowExitAnimation">@android:transition/explode</item>
    <item name="android:taskToFrontEnterAnimation">@android:transition/explode</item>
    <item name="android:taskToBackEnterAnimation">@android:transition/explode</item>
    <item name="android:taskToFrontExitAnimation">@android:transition/explode</item>
    <item name="android:taskToBackExitAnimation">@android:transition/explode</item>
    <item name="android:inAnimation">@android:transition/explode</item>
    <item name="android:layoutAnimation">@android:transition/explode</item>
    <item name="android:windowShowAnimation">@android:transition/explode</item>
    <item name="android:activityOpenEnterAnimation">@android:transition/explode</item>
    <item name="android:fragmentOpenEnterAnimation">@android:transition/explode</item>
</style>
Run Code Online (Sandbox Code Playgroud)

这就是我启动应用程序的方式:

Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.google.android.gm");
if (launchIntent != null) {
    startActivity(launchIntent);
}
Run Code Online (Sandbox Code Playgroud)

android android-animation android-launcher

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

PageViewer内部的GridView具有滞后滚动功能

我实现了一个GridView内部PageViewer,但滚动并不像它应该的那样平滑.里面GridView的意见是拦截的接触.

这让我抓狂,我已经尝试了所有的东西,虽然有一件事情起作用,但最终并不是一个好的解决方案.首先是我的代码.

apps_grid.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
    <GridView
        android:id="@+id/appGrid"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/ic_launcher_background"
        android:horizontalSpacing="4dp"
        android:numColumns="4"
        android:paddingTop="10dp"
        android:stretchMode="columnWidth"
        android:verticalSpacing="15dp"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

app_item.xml

<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="wrap_content"
    android:orientation="vertical">

    <ImageView
        android:id="@+id/icon"
        android:layout_width="54dp"
        android:layout_height="54dp"
        android:layout_gravity="center_horizontal"
        android:src="@mipmap/ic_launcher" />

    <TextView
        android:id="@+id/text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="5dp"
        android:ellipsize="end"
        android:gravity="center"
        android:paddingEnd="15dp"
        android:paddingStart="15dp"
        android:singleLine="true"
        android:text="title"
        android:textColor="@android:color/white"
        android:textSize="14sp" />

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

activity_main.xml中

<android.support.v4.view.ViewPager
    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"
    android:id="@+id/viewpager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginTop="45dp"
    android:fillViewport="true"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    />
Run Code Online (Sandbox Code Playgroud)

AppModel.java

public class AppModel {

    private String label;
    private String …
Run Code Online (Sandbox Code Playgroud)

android gridview android-gridview android-viewpager

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

Bootstrap3 Affix中的data-offset-bottom

我想设置"停止"形式我的附加元素.

示例将在http://9gag.com/上投票,它会滚动到其父容器.

我正在使用词缀,我找到了"data-offset-bottom"属性(没有记录太多)

<div id="news" class="homepage-row row">
    <div class="col-xs-3">
        <div class="ssAffix" data-spy="affix" data-offset-top="400" data-offset-bottom="800">
            123
        </div>
    </div>
    <div class="col-xs-9">
        <div id="homepage-gallery" class="product-gallery">
            gallery here
        </div>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

body {
    position:relative
}
.ssAffix {
    height: 200px;
    width: 200px;
}
.ssAffix.affix{
    top:50px;
    bottom:auto;
}
.ssAffix.affix-top{}
.ssAffix.affix-bottom{
    position:absolute;
    top:0;
    bottom:800px;
}
Run Code Online (Sandbox Code Playgroud)

首先,我不知道这应该如何运作,如何计算data-offset-bottom价值.

我只有一个词缀,我希望它能粘在它的容器中(#news)

在此之后,其他行至少有1000px的空间.


同样有趣的是,因为data-offset-bottom="800当它变成词缀底部时,元素被添加"top:-998.765625px",这个属性随着不同的data-offset-bottom值而变化

html css affix twitter-bootstrap-3

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

注意:显示临时标题

我不能调试这个消息,就像一个星期前一样.

我尝试恢复到旧文件,但这很奇怪,没有解决我的问题.

所以:我有两个长轮询请求.(关闭其中一个没有帮助).

例如,这是其中之一:

public function update_private_messages_ajax_handler(){
    global $wpdb;
    global $bp;
    $chat_table = $wpdb->prefix . 'bp_dollars_chat';

    $current_user = $bp->loggedin_user->id;

    ob_start();
    header("Content-Type: application/json");
    header("Cache-Control: no-cache, must-revalidate");
    header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");

    $startTime = time();
    while((time()-$startTime)<=20) {
        $messages = $wpdb->get_results(
            $wpdb->prepare("(SELECT * 
                FROM $chat_table 
                WHERE to_user = %d
                AND recd = 1
                AND id > %d
                ORDER BY id DESC) ORDER BY id ASC
            ", $current_user, $_POST['last_id'])
        );
        if($messages) {
            foreach($messages as $v){
                //$v->timestring = date_i18n($this->date_format.' - '.$this->time_format, $v->unix_timestamp+$this->gmt_offset);
                $v->name …
Run Code Online (Sandbox Code Playgroud)

php ajax comet long-polling google-chrome-devtools

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

数组[0]但仍包含数据

我正在使用Chrome DevTools调试我的代码,我有一个奇怪的场景.我有一个数组,其中包含数据但控制台显示数组[0]当我尝试访问它时,它给了我一个恐怖SyntaxError: Unexpected token ILLEGAL

让我向您展示详细信息:我从控制台"quick_chat"调用了一个Object,当我展开这个对象时,还有另一个名为data的Object,它显示了类似数据:Array [0],但我仍然能够扩展它哪里有另一个对象,我的聊天ID.

chatdebug

正如您在这里看到的那样,数据是Array [0],但其中包含数据.如何通过控制台访问它?有什么建议?

javascript arrays object

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