1 / 15

Tworzenie aplikacji mobilnych

Tworzenie aplikacji mobilnych. Android IMF (Input Method Framework ). android:inputType. text (domyślny) number phone datetime date time. < TextView android:text ="No special rules :"/> < EditText /> … < TextView android:text ="Email address :"/> < EditText

verena
Download Presentation

Tworzenie aplikacji mobilnych

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Tworzenie aplikacji mobilnych Android IMF (Input Method Framework)

  2. android:inputType • text (domyślny) • number • phone • datetime • date • time

  3. <TextViewandroid:text="No specialrules:"/> <EditText/> … <TextViewandroid:text="Email address:"/> <EditText android:inputType="text|textEmailAddress"/> … <TextViewandroid:text="Signeddecimalnumber:"/> <EditText android:inputType="number|numberSigned|numberDecimal"/> … <TextViewandroid:text="Date:"/> <EditText android:inputType="date"/> <TextViewandroid:text="Multi-linetext:„ /> <EditText android:inputType="text|textMultiLine|textAutoCorrect" android:minLines="3" android:gravity="top"/>

  4. Akcje po wprowadzeniu danych <EditText android:inputType="text|textEmailAddress" android:imeOptions="actionSend" /> ….. </TableRow> <TableRow> <TextView android:text="Signeddecimalnumber:" /> <EditText android:inputType="number|numberSigned|numberDecimal" android:imeOptions="actionDone" />

  5. Obsługa akcji • setOnEditorActionListener(newMyActionLisener() ) • Obsługa komunikatów przekazywanych za pomocą flag: • IME_ACTION_SEND

  6. Obsługa umieszczania IME na ekranie • Umieszczenie IME nad layutem • Zmiana rozmiaru Layout- u

  7. Własna kontrola nad wprowadzaniem danych <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.commonsware.android.imf.two" android:versionCode="1" android:versionName="1.0"> <application android:label="@string/app_name" android:icon="@drawable/cw"> <activity android:name=".IMEDemo2" android:label="@string/app_name" android:windowSoftInputMode="adjustResize"> <intent-filter> <actionandroid:name="android.intent.action.MAIN"/> <categoryandroid:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> </application> <supports-screens android:largeScreens="true" android:normalScreens="true" android:smallScreens="true" android:anyDensity="true"/> </manifest>

  8. Kontrola nad Wprowadzaniem danych(Ukrycie IME) • InputMethodManager mgr=(InputMethodManager)getSystemService(INPUT_METHOD_SERVICE); • mgr.hideSoftInputFromWindow(fld.getWindowToken(), 0); • mgr.hideSoftInputFromWindow(fld.getWindowToken(), InputMethodManager.HIDE_IMPLICIT_ONLY);

  9. Data Adapers • Dostęp do danych • Odpowiadają zarówno za dostęp do danych ja i za konwersje do odpowiednich obiektów View

  10. Przykład(generacja w obiektach TextView) • String[] items={"this", "is", "a","really", "silly", "list"}; • newArrayAdapter<String>(this,android.R.layout.simple_list_item_1, items); Context Kolekcja Layout

  11. Przykład: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:id="@+id/selection" android:layout_width="fill_parent" android:layout_height="wrap_content"/> <ListView android:id="@android:id/list" android:layout_width="fill_parent" android:layout_height="fill_parent" android:drawSelectorOnTop="false" /> </LinearLayout>

  12. Wykorzystanie ListAcivity public class ListViewDemo extends ListActivity{ privateTextViewselection; private static final String[] items={"lorem", "ipsum", "dolor","sit", "amet", "consectetuer", "adipiscing", "elit", "morbi", "vel", "ligula", "vitae", "arcu", "aliquet", "mollis", … }; @Override public voidonCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.main); setListAdapter(newArrayAdapter<String>(this, android.R.layout.simple_list_item_1, items)); selection=(TextView)findViewById(R.id.selection); } public void onListItemClick(ListView parent, View v, intposition,longid) { selection.setText(items[position]); } }

  13. Wielokrotny wybór • W kodzie:setChoiceMode()CHOICE_MODE_SINGLE CHOICE_MODE_MULTIPLE • W xml:android:choiceMode

  14. <?xml version="1.0" encoding="utf-8"?> <ListView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/list" android:layout_width="fill_parent" android:layout_height="fill_parent" android:drawSelectorOnTop="false" android:choiceMode="multipleChoice" /> public class ChecklistDemo extends ListActivity { private static final String[] items={"lorem", "ipsum", "dolor", "sit", "amet", "}; @Override public voidonCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.main); setListAdapter(newArrayAdapter<String>(this, android.R.layout.simple_list_item_multiple_choice, items));

More Related