very useful tool, who needs photoshop nowadays?!
http://pdnbulkupdater.codeplex.com/
Tuesday, February 21, 2012
Friday, February 10, 2012
Thursday, February 2, 2012
android open contextmenu when click on listview item
package androidTest.app;
import android.app.Activity;
import android.app.ListActivity;
import android.content.res. Configuration;
import android.os.Bundle;
import android.view.ContextMenu;
import android.view.ContextMenu. ContextMenuInfo;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView. OnItemLongClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class AndroidTestActivity extends Activity implements
OnItemLongClickListener {
private Activity activity = null;
private ListView _listview;
private String _selectedItem;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate( savedInstanceState);
setContentView(R.layout.main);
activity = this;
_listview = (ListView)findViewById(R.id. lvTagValues);
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_ item_1, PENS);
_listview.setAdapter( arrayAdapter);
this.registerForContextMenu(_ listview);
_listview. setOnItemLongClickListener( this);
_listview. setOnItemClickListener(
new android.widget.AdapterView. OnItemClickListener()
{
public void onItemClick(AdapterView<?> arg0, View view,
int position, long id) {
//Take action here.
_selectedItem = (String) _listview.getItemAtPosition( position);
activity.openContextMenu(_ listview);
System.out.println("...context is called");
}
}
);
}
@Override
public void onConfigurationChanged( Configuration newConfig) {
// TODO Auto-generated method stub
super.onConfigurationChanged( newConfig);
System.out.println("... 11configuration is changed...");
}
static final String[] PENS = new String[]{
"MONT Blanc",
"Gucci",
"Parker",
"Sailor",
"Porsche Design",
"item1",
"item2",
"item3",
"item4",
"item5",
"item6",
"item7",
"item8",
"item9",
"item10",
"item11"
};
@Override
public void onCreateContextMenu( ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
// TODO Auto-generated method stub
System.out.println("...on create context menu...");
super.onCreateContextMenu( menu, v, menuInfo);
menu.setHeaderTitle("Context Menu");
menu.add(0, v.getId(), 0, "Action 1");
menu.add(0, v.getId(), 0, "Action 2");
}
@Override
public boolean onContextItemSelected(MenuItem item) {
if(item.getTitle()=="Action 1"){
function1(item.getItemId());
}
else if(item.getTitle()=="Action 2"){
function2(item.getItemId());
}
else {return false;}
return true;
}
private void function1(int itemID){
System.out.println("...menu 1 is clicked" + Integer.toString(itemID));
}
private void function2(int itemID){
System.out.println("...menu 2 is clicked" + Integer.toString(itemID));
}
public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
System.out.println("...on long click close context menu...");
activity.closeContextMenu();
// TODO Auto-generated method stub
return false;
}
}
import android.app.Activity;
import android.app.ListActivity;
import android.content.res.
import android.os.Bundle;
import android.view.ContextMenu;
import android.view.ContextMenu.
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class AndroidTestActivity extends Activity implements
OnItemLongClickListener {
private Activity activity = null;
private ListView _listview;
private String _selectedItem;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(
setContentView(R.layout.main);
activity = this;
_listview = (ListView)findViewById(R.id.
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_
_listview.setAdapter(
this.registerForContextMenu(_
_listview.
_listview.
new android.widget.AdapterView.
{
public void onItemClick(AdapterView<?> arg0, View view,
int position, long id) {
//Take action here.
_selectedItem = (String) _listview.getItemAtPosition(
activity.openContextMenu(_
System.out.println("...context is called");
}
}
);
}
@Override
public void onConfigurationChanged(
// TODO Auto-generated method stub
super.onConfigurationChanged(
System.out.println("...
}
static final String[] PENS = new String[]{
"MONT Blanc",
"Gucci",
"Parker",
"Sailor",
"Porsche Design",
"item1",
"item2",
"item3",
"item4",
"item5",
"item6",
"item7",
"item8",
"item9",
"item10",
"item11"
};
@Override
public void onCreateContextMenu(
ContextMenuInfo menuInfo) {
// TODO Auto-generated method stub
System.out.println("...on create context menu...");
super.onCreateContextMenu(
menu.setHeaderTitle("Context Menu");
menu.add(0, v.getId(), 0, "Action 1");
menu.add(0, v.getId(), 0, "Action 2");
}
@Override
public boolean onContextItemSelected(MenuItem item) {
if(item.getTitle()=="Action 1"){
function1(item.getItemId());
}
else if(item.getTitle()=="Action 2"){
function2(item.getItemId());
}
else {return false;}
return true;
}
private void function1(int itemID){
System.out.println("...menu 1 is clicked" + Integer.toString(itemID));
}
private void function2(int itemID){
System.out.println("...menu 2 is clicked" + Integer.toString(itemID));
}
public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
System.out.println("...on long click close context menu...");
activity.closeContextMenu();
// TODO Auto-generated method stub
return false;
}
}
Subscribe to:
Posts (Atom)