2014年12月

Center tabbar icons fragment pager adapter?

I am using a slidingtab layout with a custom fragmentpageradpater. My icons are in the tab bar, though I want each icon to be centered in its respective place. how can i accomplish this?



Here is my fragment pager adapter:



public class MyFragmentPagerAdapter extends FragmentPagerAdapter  {

// Holds tab titles
private String tabTitles[] = new String[] { "Frag #1", "Frag #2", "Frag #3" };
private Context context;

public LiveStreamFragment liveStreamFragment;
public HeartFragment heartFragment;
public AboutFragment aboutFragment;





private int[] imageResId = {
R.drawable.ic_cassette,
R.drawable.ic_favorites,
R.drawable.ic_about
};

public MyFragmentPagerAdapter(FragmentManager fm, Context context) {
super(fm);
this.context = context;

liveStreamFragment = new LiveStreamFragment();
heartFragment = new HeartFragment();
aboutFragment = new AboutFragment();


}

public HeartFragment getHeartFragment(){
return heartFragment;
}

@Override
public int getCount() {
return 3;
}

// Return the correct Fragment based on index
@Override
public Fragment getItem(int position) {
if(position == 0){
//return new LiveStreamFragment();
return liveStreamFragment;
} else if(position == 1) {
//return new HeartFragment();
return heartFragment;
} else if(position == 2) {
//return new AboutFragment();
return aboutFragment;
}

return null;
}

@Override
public CharSequence getPageTitle(int position) {
Drawable image = context.getResources().getDrawable(imageResId[position]);
image.setBounds(0,0,80, 80);

SpannableString sb = new SpannableString(" ");
ImageSpan imageSpan = new ImageSpan(image, ImageSpan.ALIGN_BOTTOM);
sb.setSpan(imageSpan, 0, 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
return sb;
}


}





Have a trouble with returning value from async function [duplicate]

This question already has an answer here:




How to return the response from an asynchronous call?

7 answers

Answers

You need to add $apply to your async callback. Doc link.




$apply() is used to execute an expression in angular from outside of the angular framework. (For example from browser DOM events, setTimeout, XHR or third party libraries).




Also, using ngInit outside of ngRepeat is considered a bad practice, initialize scope vars in the controller.



(function getCurrentIndex(companyName) {
var indexRef = new Firebase('https://xxxxx-stock.firebaseio.com/' + companyName);
indexRef.on("value", function(Index){
$scope.Index = Index.val();
$scope.$apply();
});
})('Apple');




Question

In August 2009 I was rear-ended. Insurance company took liability in September, and in mid-September was deemed as a total loss. I released my car to the ins. co. because I did not want to retain ownership. Fast forward to June 2010. I am finally ready to settle. Ins. co. had previously given me an offer, which I took, about $7,000. I get a check in the mail for about $5,000 and in the comments section it claims that I retained ownership. Ins. co. had my car from the date it was deemed a total loss.

However it happened, I don't know... but my car was supposedly sold at an insurance auto auction and the ins. co. will not pay me the difference because they do not have the car. Well, neither do I! They said the car was deemed abandoned, and certified letters were sent to a previous lien holder and my sister, who was on the title. The letter to my sister was returned as undeliverable as addressed although it had her correct address. They're trying to claim that the car was abandoned, they "tried" to contact the owner and then sold the car. I call bs, but I don't know how to deal with it.

Here's what I'm thinking. Ins. co. contracts with holding facility, like a garage. Because they contract with them, the garage can't claim lien holder status on the car because the ins. co. is liable for holding fees, etc. Until I accepted offer, ins. co. would have to keep car, right? No matter how long (although I believe I have up to two years to settle, yes?) that it takes me to settle? The garage has ins. co. information, so when it came up to whatever point that my car was still there, 60 or whatever days and they wanted to claim it as abandoned they should have contacted the ins. co. on what to do with my car. Ins. co. would have record of whose car it was (it still had plates, vin, registration, etc) which could be matched up with an open claim. They'd then see that the claim was still open, and that nothing could be done with the car.

Am I correct in all of this? Or am I screwed? I can't see how the ins. co. can get away with this.



Answer

Call me at the office and we can talk about it. My legal assistant is Carrie. She can get you on my calendar. I don't charge for consultations.





Get tweets from twitter using xamarin.Social

Can anyone help me to get tweets from my tweeter account. I'm developing a mobile app using Xamarin.Forms in which I need to get tweets from twitter.



Currently I'm using Xamarin.Social to integrate twitter in the app and I'm able to login into my twitter account but not able to get tweets. Thanks in Advance





Ajax, Can't load xml data

While I am trying to load my xml data trough ajax it just not working..
I can't see the data display..



var xmlHttp = createXMLHttpReq();    
function createXMLHttpReq() {
var xmlHttp;
try {
xmlHttp = new XMLHttpRequest();
} catch (e) {
try {
xmlHttp = new ActiveXObject("Microsogt.XMLHTTP");
} catch (e) {
alert("Not supported for your browser");
}
}
return xmlHttp;
}

function exam(id) {
if (xmlHttp.readyState == 0 || xmlHttp.readyState == 4) {
xmlHttp.open("GET", "examajax.php?id=" + id, true);
xmlHttp.onreadystatechange = handleResponse;
xmlHttp.send();
} else {
setTimeOut(exam(), 1000);
}
}

function handleResponse() {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
data = xmlhttp.responseXML.documentElement.firstChild.data;
document.getElementById("mainform").innerHTML = data;
}
}


examajax.php file :



<?php
header("Content-Type : text/xml");
echo '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';
echo '<response>';
$id = isset($_GET['id']) ? intval($_GET['id']) : 0;
$p = isset($_GET['s_p']) ? intval($_GET['s_p']) : 1;
$loadAll = mysql_query("SELECT * FROM `questions` WHERE `testid` = $id");
$ofp = mysql_num_rows($loadAll);
$selected = (isset($_GET['sel']) && is_numeric($_GET['sel']) && $_GET['sel'] <= $ofp && $_GET['sel'] >= 1) ? $_SESSION['sel'.$p] = intval($_GET['sel']) : null;
$loadQuestion = mysql_query("SELECT * FROM `questions` WHERE `testid` = $id && `pos` = $p ORDER BY -`id` DESC LIMIT 1");
while ($question = mysql_fetch_array($loadQuestion)) {
?>
שאלה <?php echo $p; ?>/<?php echo $ofp; ?>
<?php echo $question['name']; ?>
<input type="radio" onclick="select(1,<?php echo $p; ?>)" value="<?php echo $question['op1']; ?>" />
<input type="radio" onclick="select(2,<?php echo $p; ?>)" value="<?php echo $question['op2']; ?>" />
<input type="radio" onclick="select(3,<?php echo $p; ?>)" value="<?php echo $question['op3']; ?>" />
<input type="radio" onclick="select(4,<?php echo $p; ?>)" value="<?php echo $question['op4']; ?>" />
<input type="radio" onclick="select(5,<?php echo $p; ?>)" value="<?php echo $question['op5']; ?>" />
<?php
}
echo '</response';
?>


If i'm changing the innerHTML to some string instead of data it will display the string .. but for some reason it doesn't load the xml data.. help please?





↑このページのトップヘ