小编pin*_*dol的帖子

删除linearlayout中的所有项目

我创建了一个替换为xml项的linearlayout.在这个线性布局中,我动态地放置了一些textview,因此不需要从xml中取出它们.现在我需要从linearlayout中删除这些textview.我试过这个:

if(((LinearLayout) linearLayout.getParent()).getChildCount() > 0)
    ((LinearLayout) linearLayout.getParent()).removeAllViews();
Run Code Online (Sandbox Code Playgroud)

但它不起作用.我能怎么做?谢谢,马蒂亚

android android-linearlayout

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

无法重新声明功能php

我有一个名为parseDate的函数,但是当我在我的php页面上调用它时(它是一个joomla组件页面)我得到致命错误:无法重新声明parsedate()(之前在templates/ja_zeolite/assets/functions.php:2中声明)in第21行的templates/ja_zeolite/assets/functions.php

第2行是函数解析($ data),第21行是}(函数结束).功能是:

function parseDate($date){
$items = explode('.', $date);
switch($items[1]){
    case 1: $mese = 'Gen'; break;
    case 2: $mese = 'Feb'; break;
    case 3: $mese = 'Mar'; break;
    case 4: $mese = 'Apr'; break;
    case 5: $mese = 'Mag'; break;
    case 6: $mese = 'Giu'; break;
    case 7: $mese = 'Lug'; break;
    case 8: $mese = 'Ago'; break;
    case 9: $mese = 'Set'; break;
    case 10: $mese = 'Ott'; break;
    case 11: $mese = 'Nov'; break;
    case 12: $mese = …
Run Code Online (Sandbox Code Playgroud)

php function fatal-error redeclare

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

PhpWord不替换文本

我有一个docx文件,我需要替换一些文本.这是在codeigniter框架内完成的; 这是代码:

$this->load->library('word');       
$template = $this->word->loadTemplate($_SERVER['DOCUMENT_ROOT'].'/doc/assets/doc3.docx');
$template->setValue('replacename', 'new');
$template->save($_SERVER['DOCUMENT_ROOT'].'/doc/assets/helloWorld.docx');
Run Code Online (Sandbox Code Playgroud)

当我打开新文件时,我仍然得到"new"的"replacename"instad."replacename"格式为Verdana字体,9pt字体大小(无下划线或粗体).为什么它不起作用?从setValue函数(以及doc文件)中删除$ {}它可以正常工作

php docx phpword

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

将sms设置为在Android中读取

在我的应用程序中,我需要读取仅来自一个数字的短信,当我收到它时,我需要将其设置为自动读取,而不是在sms android应用程序中设置,而是从我的应用程序.我能怎么做?谢谢!

sms android

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

Mongoose不保存嵌套的子文档

我需要在模式中保存一些子文档,该模式是模式的子文档.保存功能是这样的:

exports.add = function(req, res){
var cliente = new Cliente(req.body);
var sedi = [];

for(var key in req.body.sede){
    var sede = new Sede(req.body.sede[key]);

    var luoghi_consegna_sedi = [];

    for(jey in req.body.sede[key].lcs){
        var luogo_consegna_sede = new LuoghiConsegnaSede(req.body.sede[key].lcs[jey]);

        //Sub document
        luoghi_consegna_sedi.push(luogo_consegna_sede);
    }

    sede.luoghi_consegna_sedi = luoghi_consegna_sedi;

    //Sub docuemnt
    sedi.push(sede);
}

cliente.sedi = sedi;

cliente.save(function(err){
    if(err)
        return res.sendStatus(400);

    return res.json(cliente);
});
};
Run Code Online (Sandbox Code Playgroud)

问题是顶级父模式(cliente)保存在mongoldb上,而两种类型的子文档则没有.在cliente.sedi中,数组中填充了sede objectid,但是在mongoldb上,sede表不存在(对于luoghi_consegna_sedi也是如此).如果我在将它们推入数组之前手动保存sede和luoghi_consegna_sedi,则会创建两个表并填充数据,但如果我在cliente.sedi上运行populate(),我会得到一个空数组.3个架构是这些:Cliente

var mongoose = require('mongoose'),
Schema = mongoose.Schema;

var ClienteSchema = new Schema({
data_status: String,
status_cliente: Number,
titolo_cliente: String,
cognome: String,
nome: …
Run Code Online (Sandbox Code Playgroud)

mongoose mongodb node.js subdocument

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

在BroadcastReceiver扩展类中使用getContentResolver

我必须在扩展BroadcastReceiver的类中使用getContentResolver方法,并且我发现getContentResolver只能在扩展Activity的类中使用.我尝试在扩展活动的类中执行静态方法,但我不能在静态方法中使用getContentResolver.我也试过非静态方法但是当我运行appliaction我得到一个错误.我能怎么做?谢谢!

android broadcastreceiver android-activity

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

从另一个xml Android获取linearLayout

需要获取一个不在主xml文件中的LinearLayout(我在setContentView()中设置的那个).所以写这段代码:

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    LinearLayout main = (LinearLayout) findViewById(R.id.main1);

    LinearLayout oggetto = (LinearLayout) findViewById(R.id.element1);

    main.addView(oggetto);
}
Run Code Online (Sandbox Code Playgroud)

写入element1的xml文件是:

<?xml version="1.0" encoding="utf-8"?>
        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/element1"
            android:layout_width="fill_parent"
            android:orientation="horizontal" 
            android:layout_height="90px"
            android:background="#000000">

            <LinearLayout
                android:id="@+id/linearLayoutLeftBar"
                android:layout_width="10px"
                android:layout_height="fill_parent"
                android:orientation="horizontal"
                android:background="#7FFF00" >
            </LinearLayout>

            <LinearLayout
                android:id="@+id/linearLayoutRightContent"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:orientation="vertical"
                android:background="#EEEEEE" >

                <LinearLayout
                    android:id="@+id/linearLayout1"
                    android:layout_width="fill_parent"
                    android:layout_height="45px"
                    android:orientation="horizontal"
                    android:background="#EEEEEE" >

                    <LinearLayout
                        android:id="@+id/linearLayoutTxtView1"
                        android:layout_width="wrap_content"
                        android:layout_height="fill_parent"
                        android:orientation="vertical"
                        android:background="#EEEEEE"
                        android:layout_gravity="right" >

                        <TextView
                            android:id="@+id/textView1"
                            android:layout_width="wrap_content"
                            android:layout_height="fill_parent"
                            android:text="TextBox1"
                            android:layout_marginLeft="5px"
                            android:textColor="#000000"
                            android:gravity="center" />

                    </LinearLayout>

                    <LinearLayout
                        android:id="@+id/linearLayoutImgView"
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:orientation="vertical"
                        android:gravity="right|center" >

                        <ImageView
                            android:id="@+id/imageView1" …
Run Code Online (Sandbox Code Playgroud)

xml android android-linearlayout

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

php cookie 不更新

我需要更新一个cookie。我在通过 ajax 调用的 php 文件中执行此操作。这是代码:

setcookie('items['.$_POST['id'].']');
Run Code Online (Sandbox Code Playgroud)

cookie 不会更新,事实上,如果我在 print_r($_COOKIE['items'])setcookie 函数之后写入,我会发现它$_COOKIE['items']与调用 setcookie 函数之前的内容相同。我能怎么做?

php cookies setcookie

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

使用codeigniter将文件上传到数据库

我需要使用codeigniter在mysql数据库中上传文件.我的观点是:

<?php echo form_open_multipart('home/addpagina2'); ?>
<label for="titolo">Titolo:</label>
<input type="text" size="20" id="titolo" name="titolo"/>
<br/>
<label for="testo">Testo</label><br/>
<textarea name="testo" cols="50" rows="10"></textarea>
<br/>
<label for="file">File:</label>
<input type="file" name="file" />
<br />
<input type="submit" value="Aggiungi"/>
</form>
Run Code Online (Sandbox Code Playgroud)

和控制器是:

function addpagina2(){
    $this->form_validation->set_rules('titolo', 'Titolo', 'trim');
    $this->form_validation->set_rules('testo', 'Testo', 'trim');

    if($_FILES["file"]["size"] > 0){
        $tmpName = $_FILES["file"]['tmp_name'];         
        $fp = fopen($tmpName, 'r');
        $file = fread($fp, filesize($tmpName));
        $file = addslashes($file);
        fclose($fp);
    }

    $pagina = array();
    $pagina['titolo'] = $this->input->post('titolo');
    $pagina['testo'] = $this->input->post('testo');
    $pagina['file'] = $file;

    $this->db->insert('pagine', $pagina);
    redirect('home/pagine');
}
Run Code Online (Sandbox Code Playgroud)

当我想显示文件时,我调用此视图:

<?php
header("Content-type: ".$file['type']); …
Run Code Online (Sandbox Code Playgroud)

codeigniter file-upload

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

错误:变量初始化无效

我必须在ajax调用时才调用函数success.

码:

<script>
    function removeFromCart(id) {
        var value = "";
        for(var i=0; i<id.length; i++)
            if(!isNaN(id[i]))
                value += id[i];
        $.ajax({
            type: "POST",
            url: "http://url.com/removefromcart.php",
            data: "id="+value,
            success: function(response){
                afterRemove(response);
            }
        });
    }

    function afterRemove(response) {
        if(response[0] == "r") {
            var prezzo = "";
            for(var i = 1; i<respose.length; i++)
                var prezzo += response[i];
            document.getElementByid("prezzo").innerHTML = prezzo+".00 &euro;";
            $("#segnale"+value).fadeOut();
        }
    }
</script>
Run Code Online (Sandbox Code Playgroud)

问题是Firebug在页面加载时给出了这个错误:

invalid variable initialization: var prezzo += response[i];
Run Code Online (Sandbox Code Playgroud)

这是因为afterRemove在页面加载时调用该函数,而不仅仅是ajax成功.怎么解决这个问题?

javascript ajax jquery

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

在Android的一个角落绘制半径边框到imageview或textview

我需要在我的应用程序中为imageview或textview绘制边框,但我只需要在一个角落绘制它,就像图像一样.

在此输入图像描述

我做了一个形状,但我在所有四个方面都有边框:

<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <stroke android:width="1px" android:color="#FF000000" />
    <solid android:color="#ffffffff"/>  
    <padding android:left="1px" android:top="1px"
        android:right="0px" android:bottom="0px" />
    <corners android:topLeftRadius="8px" /> 
</shape> 
Run Code Online (Sandbox Code Playgroud)

我怎么能像在图像中那样做?

谢谢,马蒂亚

android css3

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

SelectedIndexChanged 在 C# 中的类构造函数之前调用

我在我的 C# 应用程序中创建一个名为 Acquisti 的类。然后我在表单构造函数中初始化它,然后在组合框 SelectedIndexChanged 事件中调用此类的方法。问题是,当我运行该程序时,出现错误,指出我创建的 Acquisti 类的对象为 null。这意味着 SelectedIndexChanged 事件在表单构造函数之前调用,不是吗?我也尝试过 SelectedValueChanged 事件,但我遇到了同样的问题。这是简单的代码:

Acquisti _acquisti;

    public Form1()
    {
        InitializeComponent();
        WindowState = FormWindowState.Maximized;

        for (int i = DateTime.Now.Year; i >= 2000; i--)
            annoAcquisti.Items.Add(i);

        annoAcquisti.SelectedIndex = 0;

        _acquisti = new Acquisti();
    }



    private void annoAcquisti_SelectedIndexChanged(object sender, EventArgs e)
    {
        _acquisti.load(ref acquistiDGV, annoAcquisti.SelectedItem.ToString());
    }
Run Code Online (Sandbox Code Playgroud)

c# selectedvalue selectedindexchanged winforms

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

活动之间的互动

我使用Intent从主要活动开始一个活动:

Intent i = new Intent(getApplicationContext(), InfoChiamata.class);
i.putExtra("codice_cliente", codice_cliente[tv_clicked_id]);
i.putExtra("descrizione_chiamata", descrizione_chiamata[tv_clicked_id]);
startActivity(i);
Run Code Online (Sandbox Code Playgroud)

如何编辑从Intent开始的活动中的主要活动ui?我怎么知道我什么时候从第二个活动回到主要活动?我试图覆盖onResume和onStart方法,但应用程序甚至没有启动.我试图在调用应用程序崩溃时覆盖onRestart方法.

@Override
protected void onRestart() { 
    if(call_back == 1)
        Toast.makeText(getApplicationContext(), "asd", Toast.LENGTH_LONG).show();
}
Run Code Online (Sandbox Code Playgroud)

启动时,call_back变量从辅助活动设置为1.

谢谢,马蒂亚

android android-intent android-activity

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