Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.maria_bezneayahoo.medhelper;
- import android.app.Activity;
- import android.content.Intent;
- import android.os.Bundle;
- import android.view.View;
- import android.widget.AdapterView;
- import android.widget.ArrayAdapter;
- import android.widget.EditText;
- import android.widget.ListView;
- import android.widget.TextView;
- import android.widget.Toast;
- import org.w3c.dom.Text;
- public class ListScreen extends Activity {
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- /* Set the Activity Layout */
- setContentView(R.layout.activity_list_screen);
- /* Declare intent & Get information from screen calling this one */
- Intent activityThatCalled = getIntent();
- String type = activityThatCalled.getExtras().getString("type");
- String[] results = activityThatCalled.getExtras().getStringArray("results");
- /* Set the text hint in the search box */
- EditText search_hint = (EditText) findViewById(R.id.list_search);
- search_hint.setHint("Search for " + type);
- /* Get the ListView and add the items*/
- ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.list_single_item, results);
- ListView list = (ListView) findViewById(R.id.list_items);
- list.setAdapter(adapter);
- Toast.makeText(ListScreen.this, "Everything good so far", Toast.LENGTH_LONG).show();
- /* Create onClick events for each item of the list */
- list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView<?> parent, View viewClicked, int position, long id) {
- Toast.makeText(ListScreen.this, "Everything good so far", Toast.LENGTH_LONG).show();
- /* Declare the item clicked */
- TextView textView = (TextView) viewClicked;
- String itemText = textView.getText().toString();
- textView.setText("CLICKED");
- /* Declare the intent */
- Intent showSpecificScreen = new Intent(ListScreen.this, SpecificScreen.class);
- /* Send information */
- showSpecificScreen.putExtra("header", itemText);
- /* Open the List Window */
- startActivity(showSpecificScreen);
- }
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement