Monday, 9 September 2013

Detect CTRL key pressed in Java without any event passed

Detect CTRL key pressed in Java without any event passed

I'm developing an extension in Java for a native Windows application. My
extension is launched by clicking on a button in the host application.
I've been asked to provide a different behavior for the Ctrl+click action,
but I don't have access to the mouse event since it comes from a non-Java
application and the method that I must implement is parameterless.
I can use Swing and anything else in the JDK (Java 6). What I need is a
way to test whether the Ctrl key is down at the beginning of my code.

Sunday, 8 September 2013

Dynamic Image views For User To see Pics

Dynamic Image views For User To see Pics

Trying to make my application give a cooler look am thinking of this. The
user clicks a button on an xml and as a result of this a dynamic image
gallery viewer comes in front of the user. Like we have in iphone for
changing songs. It could include an arrow to the left and right for the
user to see the next or previous picture or the user can just use the
finger to move to the next picture. I hope am sketching the right picture
to the experts here. is it possible to have such a view in android?can i
get any running examples?

check if some folders exists java Android

check if some folders exists java Android

I need check at least 4 directories if they exists and get the correct
path in a variable for finnish my code.
But I don't know the correct way to do that.
Thanks for your help.
Here my code for check a single directory
final String uploadFilePath = "/mnt/sdcard/folder1/";
File f = new File(uploadFilePath);
if(f.exists() && f.isDirectory()){
Log.v("FILES", "EXIST");
}else{
Log.v("FILES", "DONT EXIST");
}

How to retrieve informations about an item clicked in a FragmentList

How to retrieve informations about an item clicked in a FragmentList

I would like to start a profile activity when the user clicks on an item
of a listFragment. The list shows different informations about users such
as: name, id, ranking...
What I'm looking for is a way to get access to the informations about the
item clicked and pass the id of the user selected in the list to an
intent.
An AsyncTask retrieves infos from the server and calls the adapter in
order to show the details of the user in the list item. If I use in the
onListItemClick:
Object o=(Object)getListView().getItemAtPosition(position);
Log.e("LikeAttend Report", "Clicked list item: " + position + "
Content: " + o.toString());
the log returns:
Clicked list item: 1 Content: {score=7540, id=4, name= Gepp}
How can I get the id value within the method to add an Extra to the intent
and start the profile activity?
I haven't found anything useful in the reference
http://developer.android.com/reference/java/lang/Object.html
Code:
This is what I've tried so far:
public static class LikeFragmentList extends ListFragment
{
private ListView listLike;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup
container, Bundle savedInstanceState)
{
View likeView = inflater.inflate(R.layout.likelist, container,
false);
ProgressBar progress = (ProgressBar)
likeView.findViewById(R.id.loading_spinner_like);
String tabSocial="like";
listLike = (ListView) likeView.findViewById(android.R.id.list);
/*
* The asyncTask retrieves infos about the user list
*/
new AsyncLoadSocial(getActivity(), progress,
listLike).execute(uid,tabSocial);
return likeView;
}
@Override
public void onListItemClick(ListView listView, View view, int
position, long id)
{
super.onListItemClick (listView, view, position, id);
// I've tried with object and cursor
Object o = (Object) getListView().getItem(position);
//Cursor cursor = (Cursor) getListAdapter().getItem(position);
NullPointerException
Log.e("LikeAttend Report", "Clicked list item: " + position +
" Content: " +o.toString());
Intent intent = new Intent(getActivity(), Profile.class);
//intent.putExtra("id", o.toString(0)); NullPointerException
getActivity().startActivity(intent);
}
}

Accordeon change class in clicked element, easy how to do it?

Accordeon change class in clicked element, easy how to do it?

That is HTML Section:
<div class="accordion">
<div class="accord-header">
<a class="fleft">1 Title</a>
<a class="fright exp"></a>
</div>
<div class="accord-content">
ble ble ble
</div>
<div class="accord-header">
<a class="fleft">2 Title</a>
<a class="fright exp"></a>
</div>
<div class="accord-content">
bla bla bla
</div>
</div>
That is Jquery section:
$(document).ready(function() {
$(".accordion .accord-header").click(function() {
if($(this).next("div").is(":visible")){
$(this).next("div").slideUp("slow");
} else {
$(".accordion .accord-content").slideUp("slow");
$(this).next("div").slideToggle("slow");
}
});
});
Basicly what it does it is accordeon for my articles list. Now I need to
change class of element "fright exp" to "fright imp" wheen 1 tab is
clicked, same thing for next tabs. "fright exp" is symbol + and "fright
imp" is -, is there a easy way ?

Accessing at index of for cicle

Accessing at index of for cicle

I have this code:
for i in words:
print i
that report 'hello' word for 3 times. Why if:
for i in words:
print i[0]
the report is 'h' word for 3 times and not 'hello' word for 1 times? I
should report 'hello' for one time.

Reading XML using LINQ

Reading XML using LINQ

Hi I am looking for LINQ query to extract
Level1 Type, subtype
Level4 Path
from the xml sample below. I am really looking for a single LINQ query so
I can step through the resultant data.
<?xml version="1.0" encoding="utf-8"?>
<Toplevels>
<TopLevel>
<Level1>
<Type>Read this</Type>
<Subtype>Read this</Subtype>
</Level1>
<Level2>
<Level3>
<Level4>
<L4Node path="read this" />
</Level4>
</Level3>
</Level2>
</TopLevel>
<TopLevel>
<Level1>
<Type>Read this</Type>
<Subtype>Read this</Subtype>
</Level1>
<Level2>
<Level3>
<Level4>
<L4Node path="read this" />
</Level4>
</Level3>
</Level2>
</TopLevel>
<TopLevel>
<Level1>
<Type>Read this</Type>
<Subtype>Read this</Subtype>
</Level1>
<Level2>
<Level3>
<Level4>
<L4Node path="read this" />
</Level4>
</Level3>
</Level2>
</TopLevel>
</Toplevels>
can anyone help please?
Thanks in advance