Okhelp.cz

Recepty, články, nápady, programování. Dříve dum-zahrada, finance, internet a know-how.okhelp.cz Pro lepší výsledky hledání používejte i diakritiku.

View overrides onTouchEvent but not performClick


AD MOB


public class Panel extends SurfaceView implements SurfaceHolder.Callback {
//............... code
//............... some code
   /**
     * Process the MotionEvent.
     */
    @Override
    public boolean onTouchEvent(MotionEvent event) {
    	
        synchronized (getHolder()) {
            if (event.getAction() == MotionEvent.ACTION_DOWN) {
            	performClick();
             } else if (event.getAction() == MotionEvent.ACTION_MOVE) {
            	if(_currentGraphic==null)return true;
                
            } else if (event.getAction() == MotionEvent.ACTION_UP) {
            }
            return true;
        }
    }
/////////////////////////////
 @Override
 public boolean performClick() {
  // Calls the super implementation, which generates an AccessibilityEvent
        // and calls the onClick() listener on the view, if any
        super.performClick();

        // Handle the action for the custom click here

        return true;
 }

}


397LW NO topic_id




AD

Další témata ....(Topics)


340

Android Studio hide delete import module | android-studio-hide-delete-import-module


Hide module - open dialog: File > Project Structure Ctrl + Alt + Shift + S
android-studio-hide-module.jpg

Hide module: in opened Dialog select module which will hidden and click on minus (left upper corner)

android-studio-hide-module-from-project-explorer.jpg

If module is hidden, you can permanetly delete module from disk. But if you want using module in future,  copy module into other folder (not into AndroidProjects folder and his subbfolders) and delete module permanetly from project and disc. Right mouse click on module and select from menu Delete.
android-studio-delete-module-from-disc.jpg

If you want import the backup copy to project, use: File>New>Import mudule
android-studio-import-module.jpg
125

Get SensorManager PowerManager WindowManager Display Android example | get-sensormanager-powermanager-windowmanager-display-android-example



    private SensorManager mSensorManager;
    private PowerManager mPowerManager;
    private WindowManager mWindowManager;
    private Display mDisplay;

// onCreate
   @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

       // Get an instance of the SensorManager
        mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);

        // Get an instance of the PowerManager
        mPowerManager = (PowerManager) getSystemService(POWER_SERVICE);

        // Get an instance of the WindowManager
        mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
        mDisplay = mWindowManager.getDefaultDisplay();

        setContentView(R.layout.main); // main.xml or your xml file name

}

326

phpbb forum mobile friendly theme style | phpbb-forum-mobile-friendly-theme-style


- download any mobile styles for example //www.artodia.com/phpbb-styles/mobile/
- unzip style into your forum style folder for example all art_mobile folder copy into 0:/myweb/forum/styles/
- folow instalation istructions //www.artodia.com/phpbb-styles/mobile/tutorials/mobile-detection/
- check url result on https://www.google.com/webmasters/tools/mobile-friendly
2

Click Handler | click-handler-android-code


Click Handler Android Java example source code. Open new class as activity and open URL in browser.
In layout.xml file:



In string.xml

myClickHandler



In MainClass.java file

	public void myClickHandler(View view) {
		switch (view.getId()) {
		// open new class as activity
		case R.id.btnOpenClass: {
				Intent pictureActivity = new Intent(getBaseContext(),
						MyClass.class);
				startActivity(pictureActivity);
		}
		break;			
			
		case R.id.btnAbout: {
			//aboutDialogCreate();
		}
			break;
			
		// open url	
		 case R.id.btnHome: {
		 String url = "//android.okhelp.cz/";
		 Intent i = new Intent(Intent.ACTION_VIEW);
		 i.setData(Uri.parse(url));
		 startActivity(i);
		 }break;

		}

	}// end myClickHandler

// listener .. if click on button will scrolling to mTextView bottom
private OnClickListener mButtonListener = new OnClickListener() {
	    public void onClick(View v) {
	      // do something when the button is clicked
	    int nBottom =	mTextView.getBottom();
	    hScrollView.scrollTo(0, nBottom);
	    }
	};

228

Eclipse "id cannot be resolved or is not a field” error Android | eclipse-id-cannot-be-resolved-or-is-not-a-field-error-android


"id cannot be resolved or is not a field” error
If you copy project to workspace or some code from other project you can get this error.

Try remove or add import your R file:

import com.example.app.R


Check xml files.
Clean project by menu Project-Clean

Maybe you have to create new project end copy old source files to new project folders.


Editace: 2015-02-21 20:04:24
Počet článků v kategorii: 397
Url:view-overrides-ontouchevent-but-not-performclick

AD
11 Share
Share
Tweet