Android Lists Oct 2, 2012
CS 580 Client-Server Programming Fall Semester, 2012 Doc 11 Android Lists Oct 2, 2012 Copyright ©, All rights reserved. 2012 SDSU & Roger Whitney, 5500 Campanile Drive, San Diego, CA 92182-7700 USA. OpenContent (http:// www.opencontent.org/opl.shtml) license defines the copyright on this document. Tuesday, October 2, 12 Creating & Using a Jar File 2 Tuesday, October 2, 12 Java Class in Java project package edu.sdsu.cs; public class Add { public int add(int a, int b) { return a + b; } } 3 Tuesday, October 2, 12 Exporting Java Jar File Export Java Project 4 Tuesday, October 2, 12 Importing Java jar file into Android Project Drag and drop jar file into libs directory of Android Project Make sure files are copied into project for this class 5 Tuesday, October 2, 12 Using the Add Class in Android Project import edu.sdsu.cs.Add; import android.os.Bundle; import android.app.Activity; import android.view.Menu; import android.widget.TextView; public class MainActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Add adder = new Add(); int result = adder.add(1,2); TextView answer = (TextView) findViewById(R.id.answer); answer.setText("" + result); } 6 Tuesday, October 2, 12 Android Examples 7 Tuesday, October 2, 12 API Demos Show many features of Android UI Source code 8 Tuesday, October 2, 12 Loading Android Examples 9 Tuesday, October 2, 12 Lists 10 Tuesday, October 2, 12 Lists ListActivity handled much of work List View Adapter for the
[Show full text]