小编Jer*_*emy的帖子

如何以编程方式为ImageView设置动画

我正在尝试在单击所述图像视图时为ImageView设置动画.

具体来说,我希望ImageView的大小变大(比如.20更大)并立即缩小回原始大小).

到目前为止,我一直在试验这段代码而没有运气.

// thumbLike is the imageView I would like to animate.
button.setOnClickListener(new OnClickListener(){
    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
        ScaleAnimation scaleAnim = new ScaleAnimation(1.0f, 2.5f, 1.0f, 2.5f,
                                    Animation.RELATIVE_TO_SELF, 0.5f,
                                    Animation.RELATIVE_TO_SELF, 0.5f);
        scaleAnim.setInterpolator(new LinearInterpolator());
        scaleAnim.setDuration(1500);
        thumbLike.startAnimation(scaleAnim);
        thumbLike.setAnimation(null);
    }
});
Run Code Online (Sandbox Code Playgroud)

任何人都可以建议我一个可能的解决方案

编辑#1

正如Hardik4560所回答的那样,它正在通过XML工作:

// finally i use this code to execute the animation
Animation animationScaleUp = AnimationUtils.loadAnimation(this, R.anim.scale_up);
Animation animationScaleDown = AnimationUtils.loadAnimation(this, R.anim.scale_down);

AnimationSet growShrink = new AnimationSet(true);
growShrink.addAnimation(animationScaleUp);
growShrink.addAnimation(animationScaleDown);
thumbLike.startAnimation(growShrink);
Run Code Online (Sandbox Code Playgroud)

和XML

SCALE_UP
<?xml version="1.0" …
Run Code Online (Sandbox Code Playgroud)

android scaletransform android-animation

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

Android:在片段之间传递对象

在我开始之前,我已经看过如下问题:

在片段之间传递数据:屏幕重叠 如何在片段之间传递值

以及Android文档:

http://developer.android.com/training/basics/fragments/communicating.html

以及这篇文章:

http://manishkpr.webheavens.com/android-passing-data-between-fragments/

虽然上面提到的所有情况都与我的相似,但并不完全相同.我在这里遵循了一个很好的教程(我的部分代码基于这篇文章):

http://www.androidhive.info/2013/10/android-tab-layout-with-swipeable-views-1/

我有以下文件:

RegisterActivity.java
NonSwipeableViewPager.java
ScreenSliderAdapter.java
RegisterOneFragment.java
RegisterTwoFragment.java

以下布局:

activity_register.xml
fragment_register_one.xml
fragment_register_two.xml

我想要实现的是将Serializable对象从RegisterFragmentOne传递给RegisterFragmentTwo.

到目前为止,这就是我所做的(省略了一些代码):

RegisterActivity.java

public class RegisterActivity extends FragmentActivity
             implements RegisterOneFragment.OnEmailRegisteredListener{

    public static NonSwipeableViewPager viewPager;
    private ScreenSliderAdapter mAdapter;

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

        // Initilization
        mAdapter = new ScreenSliderAdapter(getSupportFragmentManager());
        viewPager = (NonSwipeableViewPager) findViewById(R.id.pager);
        viewPager.setAdapter(mAdapter);
    }

    public void onEmailRegistered(int position, Registration regData){
        Bundle args = new Bundle();
        args.putSerializable("regData", regData);
        viewPager.setCurrentItem(position, true);
    }
}
Run Code Online (Sandbox Code Playgroud)

ScreenSliderAdapter.java

public class ScreenSliderAdapter extends FragmentPagerAdapter{

    public …
Run Code Online (Sandbox Code Playgroud)

java android android-fragments

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

如何解决“FastCGI:从服务器收到的不完整标头(0 字节)”错误

我不断收到以下错误:

Wed Mar 30 01:22:43.780576 2016] [fastcgi:error] [pid 12345:tid 1234567890] [client 123.459.78.123:12345] FastCGI: incomplete headers (0 bytes) received from server "/path/to/php5-fcgi", referer: http://example.com/some/file.php
Run Code Online (Sandbox Code Playgroud)

这仅在我访问特定页面(控制器)时发生。更让我困惑的是,这个错误似乎是随机的。这意味着有时我可以很好地访问该页面,而其他时候我不断收到该错误。

我所说的页面是 Prestashop 1.5.4 的后台,特别是订单页面(后台 > 订单 > 订单)。

该页面确实向 MySQL 发送了一个查询(它花了不到一秒的时间)。这是完整的查询(已调试):

SELECT SQL_CALC_FOUND_ROWS
a.`id_order`,`reference`,`total_paid_tax_incl`,`payment`,a.date_add as date_add, 
a.id_currency,
a.id_order AS id_pdf,
CONCAT(LEFT(c.`firstname`, 1), '. ', c.`lastname`) AS `customer`,
osl.`name` AS `osname`,
os.`color`,
IF((SELECT COUNT(so.id_order) FROM `ps_orders` so WHERE so.id_customer = a.id_customer) > 1, 0, 1) as new
FROM `ps_orders` a
LEFT JOIN `ps_customer` c ON (c.`id_customer` = …
Run Code Online (Sandbox Code Playgroud)

php mysql apache prestashop

8
推荐指数
0
解决办法
2万
查看次数

如何设置放置在ImageView上的textview的背景不透明度

我希望在名称上有透明背景的情况下实现以下结果:

背景名称

到目前为止,这就是我所做的(忽略图像周围的黑色边框):

目前的结果

我想要一个透明的背景(实际上是一个调整了不透明度的彩色背景).

这是我一直使用的XML代码:

<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dp">

<ImageView
    android:id="@+id/iconItem"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:layout_gravity="center"
    android:src="@drawable/shout_ic"/>
<TextView
    android:id="@+id/textItem"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:layout_alignBottom="@+id/iconItem"
    android:paddingBottom="5dip"
    android:textSize="10sp"
    android:textColor="#FFF"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

谁能指出我如何实现这些事情的正确方向?谢谢

android background opacity textview android-imageview

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

以线性布局编程方式移动布局位置

我有以下xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" >

    <LinearLayout
        android:id="@+id/wrapper"
        android:layout_width="fill_parent"
        android:layout_height="50dp"
        android:layout_margin="10dip"
        android:weightSum="1"
        android:background="#000"
        android:orientation="horizontal">
        <TextView
            android:id="@+id/textMessage"
            android:layout_width="0dp"
            android:layout_height="fill_parent"
            android:layout_weight = ".9"
            android:layout_gravity="center"
            android:layout_margin="5dip"
            android:paddingLeft="10dip"
            android:background="#FFF"
            android:text="TEXT NOT SET"
            android:textColor="@android:color/white" />
        <ImageView
            android:id="@+id/thumbPhoto"
            android:layout_width="0dp"
            android:layout_height="fill_parent"
            android:layout_weight = ".1"
            android:src="@drawable/ic_contact_default"/>
    </LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

我想做的是让我的ImageView的位置以编程方式更改到textMessage的左侧.

这可以通过将我的ImageView放在TextView上方通过xml完成​​.但是我想以编程方式实现相同的结果.

假设我的适配器中有这个:

public View getView(int position, View convertView, ViewGroup parent) {

    View row = convertView;
    if (row == null) {
            LayoutInflater inflater = (LayoutInflater) this.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            row = inflater.inflate(R.layout.chat_item, parent, false);
    }

    wrapper = (LinearLayout) row.findViewById(R.id.wrapper);

    // …
Run Code Online (Sandbox Code Playgroud)

android android-layout android-linearlayout

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

关于记录系统中用户活动的数据库设计的建议

我想向 a 寻求关于良好的数据库设计来记录用户活动的建议。

目前我正在为一个简单的网站实施这种方法,用户可以在网站上发布/编辑/删除文章。

表日志

- log_id
- log_change[Enum: new/edit/remove]
- log_date
- member_id
- post_id
Run Code Online (Sandbox Code Playgroud)

桌柱

- post_id
- post_title
- etc....
Run Code Online (Sandbox Code Playgroud)

表成员

- member_id
- member_username
- member_pwd
- etc..
Run Code Online (Sandbox Code Playgroud)

使用此表,每次用户对文章发表新帖子(或编辑/删除)时,都会将其记录在日志中(以及发生的时间)。

但是,如果我正在处理一个更大的系统,用户不仅可以发布文章,还可以执行其他操作,例如登录/注销(从系统)、进行购买(交易)。

我应该为每个模块选择不同的表吗?例如,如果系统具有发布文章、电子商务等模块,那么我将拥有以下日志表:

  1. 文章日志
  2. 电商日志

每个表将记录每个相应模块中的活动。

database logging database-design

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

网络错误的解决方案(tcp_error)

我在其中一个页面上收到以下错误:

Network Error (tcp_error) 

A communication error occurred: "Operation timed out"
The Web Server may be down, too busy, or experiencing other problems preventing it from responding to requests. You may wish to try again at a later time.

For assistance, contact your network support team.
Run Code Online (Sandbox Code Playgroud)

我在这里找到了一些关于这个问题的答案:

http://stackoverflow.com/q/18650239/1478789
http://stackoverflow.com/questions/19944331/iis-network-error-tcp-error
http://www.howtogeek.com/forum/topic/unable-to-access-one-particular-website-from-any-browser-on-my-pc
Run Code Online (Sandbox Code Playgroud)

作为网络管理员,有什么办法可以防止这种情况发生吗?也许更改apache配置?我认为这个错误发生在客户端是否正确?

tcp

5
推荐指数
0
解决办法
2万
查看次数

libapache2-mod-fastcgi安装期间出错

我试图安装php5-fpm,但是在尝试安装libapache2-mod-fastcgi时遇到了问题.

我收到以下消息:

After this operation, 250 kB of additional disk space will be used.
Selecting previously unselected package libapache2-mod-fastcgi.
(Reading database ... 63345 files and directories currently installed.)
Preparing to unpack .../libapache2-mod-fastcgi_2.4.7~0910052141-1.1_amd64.deb ...
Unpacking libapache2-mod-fastcgi (2.4.7~0910052141-1.1) ...
Setting up libapache2-mod-fastcgi (2.4.7~0910052141-1.1) ...
apache2_invoke: Enable module fastcgi
Action 'configtest' failed.
The Apache error log may have more information.
apache2_reload: Your configuration is broken. Not restarting Apache 2
Run Code Online (Sandbox Code Playgroud)

我将很快发布我的apache日志,因为它是一个大文件,我需要先解析它.

顺便说一句,我做了一个快速:

grep -RIs "FastCgiExternalServer" /etc/apache2
Run Code Online (Sandbox Code Playgroud)

并得到以下回应:

/etc/apache2/conf-available/php5-fpm.conf:FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -socket /var/run/php5-fpm.sock -pass-header Authorization
Run Code Online (Sandbox Code Playgroud)

这也是,当我尝试重启Apache时: …

php fastcgi apache2

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

PHP-FPM 无法连接到 FastCGI 服务器

所以我第一次设置 PHP5-FPM,一开始一切都很顺利,我可以看到我的网站启动并运行,直到我做了一些调整

/etc/php5/fpm/pool.d/www.conf
Run Code Online (Sandbox Code Playgroud)

具体在这些方面:

pm.max_children = 100 # The hard-limit total number of processes allowed
pm.start_servers = 20 # When nginx starts, have this many processes waiting for requests
pm.min_spare_servers = 10 # Number spare processes nginx will create
pm.max_spare_servers = 20 # Number spare processes attempted to create
pm.process_idle_timeout = 10s;
Run Code Online (Sandbox Code Playgroud)

当我重新启动 apache 和 php5-fpm 服务时,出现以下错误:

[Wed Nov 25 02:39:43.973654 2015] [fastcgi:error] [pid 5438] (2)No such file or directory: [client 36.72.129.207:60098] FastCGI: failed to connect to server "/usr/lib/cgi-bin/php5-fcgi": connect() …
Run Code Online (Sandbox Code Playgroud)

php apache fastcgi

5
推荐指数
0
解决办法
2845
查看次数

CodeIgniter PHPWord用作third_party

我正在尝试使用PHPWord并且难以使用它.

这是我在application/libraries/words.php中的代码

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

require_once APPPATH."/third_party/PhpWord/Autoloader.php"; 

\PhpOffice\PhpWord\Autoloader::register(); \\NOT SURE IF THIS IS CORRECT

class Word extends PhpWord { 
    public function __construct() { 
        parent::__construct(); 
    } 
}
Run Code Online (Sandbox Code Playgroud)

基于PHPWord github,我必须像这样使用它:

Alternatively, you can download the latest release from the releases page. In this case, you will have to register the autoloader.

require_once 'path/to/PhpWord/src/PhpWord/Autoloader.php';
\PhpOffice\PhpWord\Autoloader::register(); // WHERE SHOULD I PUT THIS?
Run Code Online (Sandbox Code Playgroud)

当我尝试从我的控制器加载库时:

$this->load->library('word');
Run Code Online (Sandbox Code Playgroud)

它给我的错误说:

Fatal error: Class 'PhpWord' not found in C:\xampp\htdocs\path\to\application\libraries\Word.php on line 7
Run Code Online (Sandbox Code Playgroud)

我试图扩展Autoloader类,但PHP仍然抱怨它找不到Autoloader.php. …

php codeigniter phpword

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