Monday, April 16, 2012

Can I set viewpager's item width?

I hope I can show 3 items in a page of viewpager, but now I only could set viewpager's padding value and margin value, so it only show one item in a page of viewpager. How can I set the item width? I think if I can set more little width of item, the viewpager will show more items in a page.





Can anyone help me with this logic test?

I was given the following question in an interview, and I came up with the code below to compute the sum the code works and is correct, but I was told that this was a logic question and they weren't looking for the source code, can anyone shed a light on this? did they want me to write the pseudo code perhaps?




  1. Compute the following sum:
    1/2 + 1/4 + 1/8 + ... + 1/1048576



    private static double computeSum()

    {
    double x = 0.0;

    for(double i=2; i<=1048576; i*=2)
    {

    x += (1 / i);

    }

    return x;
    }





ontouch and onclick on a textview not working

have a look at the code below...
i am setting the onclick listener on the textview and the ontouch listener but none of them is working...



what seems to be the problem>....?



    AlertDialog.Builder builder;
AlertDialog a;
TextView text,txtNewUser ;
ImageView image;
View layout;
Button ok;
String pswrd;
LayoutInflater inflater;

@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
final Context mContext = this;
Dialog dialog = new Dialog(mContext);
inflater = (LayoutInflater) mContext
.getSystemService(LAYOUT_INFLATER_SERVICE);
ok = (Button) findViewById(R.id.buttonOK);

dialog.setContentView(R.layout.custom_dialog_private_space);
dialog.setTitle("Password");
dialog.setCancelable(true);
layout = inflater.inflate(R.layout.custom_dialog_private_space,
(ViewGroup) findViewById(R.id.layout));
text = (TextView) dialog.findViewById(R.id.tvDesc);
txtNewUser = (TextView) dialog.findViewById(R.id.tvNewUser);

image = (ImageView) layout.findViewById(R.id.image);
image.setImageResource(R.drawable.lock_symbol_android);

builder = new AlertDialog.Builder(mContext);
builder.setView(layout);

a = builder.create();
a.show();

txtNewUser.setOnTouchListener(new OnTouchListener() {

@Override
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
if(event.getAction() == MotionEvent.ACTION_UP)
Toast.makeText(mContext, "Clicked", Toast.LENGTH_SHORT).show();
Log.v("AS", "Clicked");
return true;

}
});

txtNewUser.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Toast.makeText(mContext, "Clicked", Toast.LENGTH_SHORT).show();
Log.v("AS", "Clicked");
}
});
}


here is the code of textview from the xml of the dialog layout



<?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="fill_parent"
android:orientation="vertical"
android:id="@+id/layout" >

<TextView android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/tvNewUser"
android:text="New User?"
android:layout_gravity="top|left"
android:clickable="true"

/>

<ImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>

<TextView
android:id="@+id/tvDesc"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Enter password"
android:textAppearance="?android:attr/textAppearanceLarge"
/>



<EditText
android:id="@+id/etPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="100"
android:inputType="textPassword" >


</EditText>

<Button
android:id="@+id/buttonOK"
android:layout_width="100dp"
android:layout_gravity="center"
android:layout_height="fill_parent"
android:text="OK" />

</LinearLayout>




Why postfix milter sends command "A" instead of "Q"?

I'm using milter(from a python library) now, I found when I issue a "QUIT" command in my client, instead of sending "Q" to milter server, it sends an "A"(Abort), Is that normal?





flash is not working in codeignitor

<div id="content1">



AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0','width','595','height','305','src','rev_1','quality','high','wmode','transparent','pluginspage','http://www.macromedia.com/go/getflashplayer','movie','rev_1' ); //end AC code









1)this code is not working in the codeigntor
2)this code call a image how to find path of that image
3)plase respnd





Ajax doesn't trigger server action

I am trying to trigger action via ajax but it doesn't call from some reason. Is my js code fine?



@Html.ActionLink("LIKE", "LikeComment", "Comments", new { id = 1985 }, new{@class = "likeButton"})

$(document).ready(function () {
$(".likeButton").click(function () {
$.ajax({
url: $(this).data("action-url"),
cache: false,
success: function (html) {
alert('ss');
}
});
return false;
});
});




Execute functions in order

I want to execute 3 functions in a certain order and I do this:



function nextPage() {
var loading_temp = $('#loading_temp');

loading_temp.show()
.queue(function() {
nextPage980()
.queue(function() {
loading_temp.hide();
$(this).dequeue();
});
$(this).dequeue();
});
}


The '#loading_temp' shows up and then the function executes, but the last function (hide the loading gif) does not execute!



Chrome gives this error: Uncaught TypeError: Cannot call method 'queue' of undefined



The nextPage980() function is this:



function nextPage980() {
var ajax_heading = $('#ajax_heading');
var cur_heading = $('#cur_heading');
var temp_heading = $('.temp_heading');
var temp_heading_first = temp_heading.filter(':first');
var loading_temp = $('#loading_temp');

var htmlHeader = "?????????????";

ajax_heading.attr('class', 'next_temp');
cur_heading.css({'margin-right' : '20px'}).after('<div id="cur_heading" class="temp_heading" data-tempPos="2"><h1 class="page_heading"><span class="heading_span">' + htmlHeader + '</span></h1></div>')
.queue(function() {
ajax_heading.animate({'margin-left' : '-1000px'}, 1000, 'easeInExpo')
.queue(function() {
temp_heading_first.remove();
cur_heading.removeAttr('style');
ajax_heading.attr('class', 'cur_temp').removeAttr('style');
$(this).dequeue();
});
$(this).dequeue();
});
}


Thanks in advance!