Fabrice Di Meglio | 26e432d | 2011-06-10 14:19:18 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.bidi; |
| 18 | |
Fabrice Di Meglio | 54d6962 | 2011-07-15 16:46:44 -0700 | [diff] [blame^] | 19 | import android.app.AlertDialog; |
Fabrice Di Meglio | 7af0522 | 2011-06-10 15:42:05 -0700 | [diff] [blame] | 20 | import android.app.Fragment; |
Fabrice Di Meglio | 26e432d | 2011-06-10 14:19:18 -0700 | [diff] [blame] | 21 | import android.os.Bundle; |
Fabrice Di Meglio | 7af0522 | 2011-06-10 15:42:05 -0700 | [diff] [blame] | 22 | import android.view.LayoutInflater; |
| 23 | import android.view.View; |
| 24 | import android.view.ViewGroup; |
Fabrice Di Meglio | 54d6962 | 2011-07-15 16:46:44 -0700 | [diff] [blame^] | 25 | import android.widget.Button; |
Fabrice Di Meglio | 26e432d | 2011-06-10 14:19:18 -0700 | [diff] [blame] | 26 | |
Fabrice Di Meglio | 7af0522 | 2011-06-10 15:42:05 -0700 | [diff] [blame] | 27 | public class BiDiTestBasic extends Fragment { |
Fabrice Di Meglio | 54d6962 | 2011-07-15 16:46:44 -0700 | [diff] [blame^] | 28 | |
| 29 | private View currentView; |
| 30 | private Button alertDialogButton; |
| 31 | private String[] items = {"This is a very very very very very very very very very very very long Item1", "Item2"}; |
| 32 | |
Fabrice Di Meglio | 26e432d | 2011-06-10 14:19:18 -0700 | [diff] [blame] | 33 | @Override |
Fabrice Di Meglio | 7af0522 | 2011-06-10 15:42:05 -0700 | [diff] [blame] | 34 | public View onCreateView(LayoutInflater inflater, ViewGroup container, |
| 35 | Bundle savedInstanceState) { |
Fabrice Di Meglio | 54d6962 | 2011-07-15 16:46:44 -0700 | [diff] [blame^] | 36 | currentView = inflater.inflate(R.layout.basic, container, false); |
| 37 | return currentView; |
| 38 | } |
| 39 | |
| 40 | @Override |
| 41 | public void onViewCreated(View view, Bundle savedInstanceState) { |
| 42 | super.onViewCreated(view, savedInstanceState); |
| 43 | |
| 44 | alertDialogButton = (Button) currentView.findViewById(R.id.button_alert_dialog); |
| 45 | alertDialogButton.setOnClickListener(new View.OnClickListener() { |
| 46 | public void onClick(View v) { |
| 47 | showDialog(); |
| 48 | } |
| 49 | }); |
| 50 | } |
| 51 | |
| 52 | private void showDialog() { |
| 53 | AlertDialog.Builder builder = new AlertDialog.Builder(currentView.getContext()); |
| 54 | builder.setSingleChoiceItems(items, 0, null); |
| 55 | builder.show(); |
Fabrice Di Meglio | 26e432d | 2011-06-10 14:19:18 -0700 | [diff] [blame] | 56 | } |
| 57 | } |