Archive for 'Padding'

Sencha Forms For Connecting With PHP

The following code snippet will create an EmployeeCreateForm in sencha. Try this out:

EmployeeCreateForm = new Ext.FormPanel({
labelAlign: 'top',
bodyStyle:'padding:5px',
width: 600,
items: [{
layout:'column',
border:false,
items:[{
columnWidth:0.5,
layout: 'form',
border:false,
items: [FirstNameField, LastNameField]
}
}],
buttons: [{
text: 'Save and Close',
handler: createEmployee
},{
text: 'Cancel',
handler: function(){
EmployeeCreateForm.hide();
}
}]
});

EmployeeCreateForm= new Ext.Window({
id: 'EmployeeCreateForm',
title: 'Creating a New Employee',
closable:true,
width: 610,
height: 250,
plain:true,
layout: 'fit',
items: EmployeeCreateForm
});
public class Test extends ListActivity implements OnScrollListener {

    Aleph0 adapter = new Aleph0();

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setListAdapter(adapter); 
        getListView().setOnScrollListener(this);
    }

    public void onScroll(AbsListView view,
        int firstVisible, int visibleCount, int totalCount) {

        boolean loadMore = /* maybe add a padding */
            firstVisible + visibleCount >= totalCount;

        if(loadMore) {
            adapter.count += visibleCount; // or any other amount
            adapter.notifyDataSetChanged();
        }
    }

    public void onScrollStateChanged(AbsListView v, int s) { }    

    class Aleph0 extends BaseAdapter {
        int count = 1; /* starting amount */

        public int getCount() { return count; }
        public Object getItem(int pos) { return pos; }
        public long getItemId(int pos) { return pos; }

        public View getView(int pos, View v, ViewGroup p) {
                TextView view = new TextView(Test.this);
                view.setText("List Item " + pos);
                return view;
        }
    }
}

This will create a list integers. On reaching the end of list next 10 will be loaded into list. This is efficient way to load chunks of items in a long list.

Incoming search terms:

  • android load list in chunks

Use of str_pad in php

This functions returns the input string padded on the left, the right, or both sides to the specified padding length. If the optional argument pad_string is not supplied, the input is padded with spaces, otherwise it is padded with characters from pad_string up to the limit.

<?php
$input = "Hello";
echo str_pad($input, 10);                      // produces "Hello     "
echo str_pad($input, 10, "-=", STR_PAD_LEFT);  // produces "-=-=-Hello"
echo str_pad($input, 10, "_", STR_PAD_BOTH);   // produces "__Hello___"
echo str_pad($input, 6 , "___");               // produces "Hello_"
?>
We Can Build Your App for You. Lets Get Started !