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;
}
}
Friday, December 16, 2011
WPF Performance Suite
Guide
http://msdn.microsoft.com/en-us/library/aa969767(v=VS.90).aspx
Install Path:
Program Files\Microsoft Windows Performance Toolkit\WPF Performance Suite\WpfPerf.exe
http://msdn.microsoft.com/en-us/library/aa969767(v=VS.90).aspx
Install Path:
Program Files\Microsoft Windows Performance Toolkit\WPF Performance Suite\WpfPerf.exe
Monday, December 5, 2011
Root Samsung Exhibit II
http://androidforums.com/exhibit-4g-all-things-root/444258-anyone-root-samsung-exhibit-ii-4g-t679.html
ZergRush zip file attached.Install the phone drivers on your pc, in your phone turn usb debugging on, plug your phone into your pc and let the drivers install.Unzip the zergRush file to a new folder on your desktop,open the folder and click on the .bat file and let it run
. To check if you rooted...you should see apps called superuser and terminal emulator in your app draw. You can also download root checker from the market to verify...enjoy.
This WORKS for the Exhibit 4g ll and Exhibit 4g.
ZergRush zip file attached.Install the phone drivers on your pc, in your phone turn usb debugging on, plug your phone into your pc and let the drivers install.Unzip the zergRush file to a new folder on your desktop,open the folder and click on the .bat file and let it run
This WORKS for the Exhibit 4g ll and Exhibit 4g.
Monday, November 21, 2011
How To Make Your Application Delete Itself
XP:
none-XP
reference:
http://www.codeproject.com/KB/threads/HowToDeleteCurrentProcess.aspx
Process.Start("cmd.exe", "/C ping 1.1.1.1 -n 1 -w 3000 > Nul & Del " +
Application.ExecutablePath); none-XP
Process.Start("cmd.exe",
"/C choice /C Y /N /D Y /T 3 & Del " + Application.ExecutablePath);
Application.Exit();reference:
http://www.codeproject.com/KB/threads/HowToDeleteCurrentProcess.aspx
Saturday, November 19, 2011
System.Windows.Forms.Cursor.Hide
http://msdn.microsoft.com/en-us/library/system.windows.forms.cursor.hide.aspx
The Show and Hide method calls must be balanced. For every call to the Hide method there must be a corresponding call to the Show method.
坑爹啊...
Wednesday, November 9, 2011
Understanding User Interface in Android
http://mobiforge.com/designing/story/understanding-user-interface-android-part-1-layouts
http://mobiforge.com/designing/story/understanding-user-interface-android-part-2-views
http://mobiforge.com/designing/story/understanding-user-interface-android-part-3-more-views
http://mobiforge.com/designing/story/understanding-user-interface-android-part-4-even-more-views
http://mobiforge.com/designing/story/understanding-user-interface-android-part-2-views
http://mobiforge.com/designing/story/understanding-user-interface-android-part-3-more-views
http://mobiforge.com/designing/story/understanding-user-interface-android-part-4-even-more-views
DroidDraw Beta
Comsuming WCF Services With Android
Android ListView and ListActivity - Tutorial
Subscribe to:
Posts (Atom)