Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2. In the simple list: A.why it is necessary to use android:id attribute as @id/android:list rather than using @+id/ B.How this changes the way to

2.

In the simple list:

A.why it is necessary to use android:id attribute as @id/android:list rather than using @+id/

B.How this changes the way to grab the ListView widget in the relevant java class instead of using findViewById method?

Add a ListView with an android:id of @android:id/list to your layout, where you want the list to appear.

Or, delete your onCreateView() implementation, so you get the inherited ListView that you get from ListFragment.

Or, change your fragment to inherit from Fragment, not ListFragment and manage a ListView by yourself.

Or, change your fragment to inherit from Fragment and do not attempt to show a list in it.

3.Clarify the benefits of using DialogFragment subclass as an alternative of using dialog helper methods in the Activity class.

4.Clarify the differences between the types of location sensors built-in to the mobile device. And how the Location information is accessed within an app?

5.

Illustrate the concept of how sensors and managers used to access sensor data to create a compass that calculate the device heading.

package com.example.daycalculator;

import java.util.ArrayList;

import java.util.List;

import android.app.Activity;

import android.os.Bundle;

import android.view.View;

import android.view.View.OnClickListener;

import android.widget.ArrayAdapter;

import android.widget.Button;

import android.widget.Spinner;

import android.widget.Toast;

import android.widget.EditText;

public class MainActivity extends Activity {

private Spinner spinner1, spinner2;

private EditText EditText;

private Button btnSubmit;

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

addItemsOnSpinner2();

addListenerOnButton();

addListenerOnSpinnerItemSelection();

}

// add items into spinner dynamically

public void addItemsOnSpinner2() {

spinner2 = (Spinner) findViewById(R.id.day);

List list = new ArrayList();

list.add("1"); list.add("2");list.add("3");list.add("4");list.add("5");list.add("6");list.add("7");

list.add("8");list.add("9");list.add("10");list.add("11");list.add("12");list.add("13");list.add("14");

list.add("15");list.add("16");list.add("17");list.add("18");list.add("19"); list.add("20");list.add("21");

list.add("22");list.add("23");list.add("24");list.add("25");list.add("26");list.add("27");

list.add("28");list.add("29");list.add("30");list.add("31");

ArrayAdapter dataAdapter = new ArrayAdapter(this,

android.R.layout.simple_spinner_item, list);

dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

spinner2.setAdapter(dataAdapter);

}

public void addListenerOnSpinnerItemSelection() {

spinner1 = (Spinner) findViewById(R.id.month);

spinner1.setOnItemSelectedListener(new CustomOnItemSelectedListener());

}

// get the selected dropdown list value

public void addListenerOnButton() {

spinner1 = (Spinner) findViewById(R.id.month);

spinner2 = (Spinner) findViewById(R.id.day);

setEditText((EditText) findViewById(R.id.year));

btnSubmit = (Button) findViewById(R.id.btnSubmit);

btnSubmit.setOnClickListener(new OnClickListener() {

@Override

public void onClick(View v) {

Toast.makeText(MainActivity.this,

"OnClickListener : " +

" Spinner 1 : "+ String.valueOf(spinner1.getSelectedItem()) +

" Spinner 2 : "+ String.valueOf(spinner2.getSelectedItem()),

Toast.LENGTH_SHORT).show();

}

});

}

public EditText getEditText() {

return EditText;

}

public void setEditText(EditText editText) {

EditText = editText;

}

}

PLease write by computer and answer all question.. THANKS

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

101 Database Exercises Text Workbook

Authors: McGraw-Hill

2nd Edition

0028007484, 978-0028007489

More Books

Students also viewed these Databases questions