Write a snippet of code that logs or displays the coordinate of the touch event when the finger is pressed on the screen of your App.
The code has been written using the onCreate Bundle and it is the easiest way we could do the certain tasks performed below:
Activity Code:
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final TextView tv = (TextView)findViewById(R.id.tv);
// It will listen to all the touch activities
final View touch = findViewById(R.id.touch);
touch.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent ev) {
//Returning the touched co-ordinates
tv.setText("Co-ordinates of Area Touched : " +String.valueOf(ev.getX()) + "X" + String.valueOf(ev.getY()));
return true;
}
});
}
Layout Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android:id"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:id="@+id/touch"
android:background="#fff"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:id="@+id/tv"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Getting Co-ordinates"
/>
</LinearLayout>
Please rate the answer if it helped.....Thankyou
Hope it helps....
Write a snippet of code that logs or displays the coordinate of the touch event when...
1. Write a code snippet Write a code snippet that asks the user to enter a name and a major one at a time and creates a dictionary with keys corresponding to names and values corresponding to majors. Assume that the user enters “alice”, “bio”, “mark”, “engineering”. >>>d = {} >>> your code starts here 2.Based on your code above: >>> print(d) 3.Write a code snippet Write a code snippet that creates a dictionary (records) using keys from a frozenset...
Android Development Question: Let’s assume that your App has an EditText control and a Button in a layout. Write a snippet of code such that when the Button is pressed, the virtual keyboard will be hidden.
Write and register an event handler that displays "Event reaction" on the console log when the p receives a click event. HTML JavaScript 1 var pElement = document.getElementsByTagName("p")[0]; HNM+ 3 * Your solution goes here */ HTML JavaScript U AWNE <h1>Header 1</h1> <h2>Header 2</h2> 3 <h3>Header 3</h3> 4 <p>Paragraph</p> 5 <a href="https://www.example.org/">Example.org</a>
Create an external JavaScript file/code and then write a function that displays an alert box. This box will display when the user clicks the submit button to submit the information typed in the form, so be sure the alert box contains an appropriate message. please use the OnClick event handler for your form's submit button.
Write a code snippet (segment not a whole program) that sums the values at the corners of an X by Y 2-dimensional array.
For each block diagram presented. Write a code snippet, not a whole module, that will implement the functionality shown. Also, identify the type of circuit (e.g., combinational, sequential, or synchronous sequential). _____ (52-1 पर a look a
2. a)Write the ARM ALP conditional code snippet for the following statements written in C-language. Assume R1 to Rn as06 variables Let R1, R2, R3 contain the starting addresses of arrays X, Y and Z respectively Use Register R4 for variable i. Display appropriate messages. While (i+10) else Z[i] XiYi; b)i Write a program to display a message "This is an examination Question" on the screen using 06 a function sub program Note the following Address of the string to...
Write a JAVA code snippet which prints out numbers between 0 and 1,000,000, BUT only print the numbers which are a multiple of 3.
Write a MATLAB code that can convert a vector in any coordinate system to the other two coordinate systems. The code must ask the use to select in which coordinate system is the entered data. Write a MATLAB code that can convert a vector in any coordinate system (Cartesian, cylindrical or spherical) to the other two coordinate systems. The code must ask the use to select in which coordinate system is the entered data.
Question 6: What is wrong with this code snippet? that solves the problem Provide an example situation when the code won't work, and an alternative Your Solution: choice -input('What is your choice? ''S' if choice-YES , a=5 ; else a=0; end