Example usage for android.view LayoutInflater inflate

List of usage examples for android.view LayoutInflater inflate

Introduction

In this page you can find the example usage for android.view LayoutInflater inflate.

Prototype

public View inflate(XmlPullParser parser, @Nullable ViewGroup root) 

Source Link

Document

Inflate a new view hierarchy from the specified xml node.

Usage

From source file:com.danielme.muspyforandroid.activities.base.AbstractActivity.java

private void showToast(int msgID, String msg, int duration) {
    Toast toast = new Toast(this);
    LayoutInflater inflater = getLayoutInflater();
    View layout = inflater.inflate(R.layout.toast_success, (ViewGroup) findViewById(R.id.lytLayout));

    TextView txtMsg = (TextView) layout.findViewById(R.id.toastMessage);

    if (msg == null) {
        txtMsg.setText(getString(msgID));
    } else {/*w  w w. ja va 2s.c  o m*/
        txtMsg.setText(msg);
    }
    toast.setDuration(duration);
    toast.setView(layout);
    toast.show();
}

From source file:org.envirocar.app.activity.LoginFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    setHasOptionsMenu(true);//from  ww  w.  j  a va 2s .  co  m

    View view = inflater.inflate(R.layout.login_layout, null);

    mUsernameView = (EditText) view.findViewById(R.id.login_username);

    mPasswordView = (EditText) view.findViewById(R.id.login_password);
    mPasswordView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
            if (id == R.id.login || id == EditorInfo.IME_NULL) {
                attemptLogin();
                return true;
            }
            return false;
        }
    });
    mLoginFormView = view.findViewById(R.id.login_form);
    mLoginStatusView = view.findViewById(R.id.login_status);
    mLoginStatusMessageView = (TextView) view.findViewById(R.id.login_status_message);

    view.findViewById(R.id.sign_in_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            attemptLogin();
        }
    });

    view.findViewById(R.id.not_yet_registered_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            openRegisterFragment();
        }
    });
    return view;
}

From source file:gov.wa.wsdot.android.wsdot.ui.BlogFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_list_with_swipe_refresh, null);

    // For some reason, if we omit this, NoSaveStateFrameLayout thinks we are
    // FILL_PARENT / WRAP_CONTENT, making the progress bar stick to the top of the activity.
    root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    swipeRefreshLayout = (SwipeRefreshLayout) root.findViewById(R.id.swipe_container);
    swipeRefreshLayout.setOnRefreshListener(this);
    swipeRefreshLayout.setColorScheme(17170451, // android.R.color.holo_blue_bright 
            17170452, // android.R.color.holo_green_light 
            17170456, // android.R.color.holo_orange_light 
            17170454); // android.R.color.holo_red_light)

    mEmptyView = root.findViewById(R.id.empty_list_view);

    return root;//w  w w  .j  a va  2  s .c  o  m
}

From source file:fib.lcfib.raco.Controladors.ControladorLoginRaco.java

private void showAddDialog() {

    loginDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND,
            WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
    loginDialog.setTitle(R.string.loginRaco);

    LayoutInflater li = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View dialogView = li.inflate(R.layout.contingut_login, null);
    loginDialog.setContentView(dialogView);

    username = (EditText) dialogView.findViewById(R.id.login);
    password = (EditText) dialogView.findViewById(R.id.password);

    Button okButton = (Button) dialogView.findViewById(R.id.acceptar_button);
    Button cancelButton = (Button) dialogView.findViewById(R.id.cancel_button);
    loginDialog.setCancelable(false);//from w ww.  ja  v  a  2 s . com
    loginDialog.show();

    okButton.setOnClickListener(new OnClickListener() {
        // @Override
        public void onClick(View v) {
            try {
                String usernameAux = username.getText().toString().trim();
                String passwordAux = password.getText().toString().trim();

                usernameAux = URLEncoder.encode(usernameAux, "UTF-8");
                passwordAux = URLEncoder.encode(passwordAux, "UTF-8");

                boolean correcte = check_user(usernameAux, passwordAux);
                if (correcte) {
                    Toast.makeText(getApplicationContext(), R.string.login_correcte, Toast.LENGTH_LONG).show();
                } else {
                    Toast.makeText(getApplicationContext(), R.string.errorLogin, Toast.LENGTH_LONG).show();
                }

                if ("zonaRaco".equals(queEs)) {
                    Intent intent = new Intent(ControladorLoginRaco.this, ControladorTabIniApp.class);
                    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                    intent.putExtra("esLogin", "zonaRaco");
                    startActivity(intent);

                } else {
                    Intent act = new Intent(ControladorLoginRaco.this, ControladorTabIniApp.class);
                    // Aquestes 2 lnies provoquen una excepci per no peta
                    // simplement informa s normal
                    act.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    act.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                    startActivity(act);
                }
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
        }

        private boolean check_user(String username, String password) {

            GestorCertificats.allowAllSSL();
            AndroidUtils au = AndroidUtils.getInstance();
            /** open connection */

            //Aix tanquem les connexions segur
            System.setProperty("http.keepAlive", "false");

            try {
                InputStream is = null;
                HttpGet request = new HttpGet(au.URL_LOGIN + "username=" + username + "&password=" + password);
                HttpClient client = new DefaultHttpClient();
                HttpResponse response = client.execute(request);
                final int statusCode = response.getStatusLine().getStatusCode();
                if (statusCode != HttpStatus.SC_OK) {
                    Header[] headers = response.getHeaders("Location");
                    if (headers != null && headers.length != 0) {
                        String newUrl = headers[headers.length - 1].getValue();
                        request = new HttpGet(newUrl);
                        client.execute(request);
                    }
                }

                /** Get Keys */
                is = response.getEntity().getContent();
                ObjectMapper m = new ObjectMapper();
                JsonNode rootNode = m.readValue(is, JsonNode.class);

                is.close();
                client.getConnectionManager().closeExpiredConnections();

                if (rootNode.isNull()) {
                    return false;
                } else {

                    // GenerarUrl();
                    /** calendari ics */
                    String KEYportadaCal = rootNode.path("/ical/portada.ics").getTextValue().toString();

                    /** calendari rss */
                    String KEYportadaRss = rootNode.path("/ical/portada.rss").getTextValue().toString();

                    /** Avisos */
                    String KEYavisos = rootNode.path("/extern/rss_avisos.jsp").getTextValue().toString();

                    /** Assigraco */
                    String KEYAssigRaco = rootNode.path("/api/assigList").getTextValue().toString();

                    /** Horari */
                    String KEYIcalHorari = rootNode.path("/ical/horari.ics").getTextValue().toString();

                    /**Notificacions */
                    String KEYRegistrar = rootNode.path("/api/subscribeNotificationSystem").getTextValue()
                            .toString();

                    String KEYDesregistrar = rootNode.path("/api/unsubscribeNotificationSystem").getTextValue()
                            .toString();

                    SharedPreferences sp = getSharedPreferences(PreferenciesUsuari.getPreferenciesUsuari(),
                            MODE_PRIVATE);
                    SharedPreferences.Editor editor = sp.edit();

                    /** Save Username and Password */
                    editor.putString(AndroidUtils.USERNAME, username);
                    editor.putString(AndroidUtils.PASSWORD, password);

                    /** Save Keys */
                    editor.putString(au.KEY_AGENDA_RACO_XML, KEYportadaRss);
                    editor.putString(au.KEY_AGENDA_RACO_CAL, KEYportadaCal);
                    editor.putString(au.KEY_AVISOS, KEYavisos);
                    editor.putString(au.KEY_ASSIG_FIB, "public");
                    editor.putString(au.KEY_ASSIGS_RACO, KEYAssigRaco);
                    editor.putString(au.KEY_HORARI_RACO, KEYIcalHorari);
                    editor.putString(au.KEY_NOTIFICACIONS_REGISTRAR, KEYRegistrar);
                    editor.putString(au.KEY_NOTIFICACIONS_DESREGISTRAR, KEYDesregistrar);

                    /** Save changes */
                    editor.commit();
                }
                return true;

            } catch (ProtocolException e) {
                Toast.makeText(getApplicationContext(), R.string.errorLogin, Toast.LENGTH_LONG).show();
                return false;
            } catch (IOException e) {
                Toast.makeText(getApplicationContext(), R.string.errorLogin, Toast.LENGTH_LONG).show();
                return false;
            }

        }
    });

    cancelButton.setOnClickListener(new OnClickListener() {
        // @Override
        public void onClick(View v) {
            Intent act = new Intent(ControladorLoginRaco.this, ControladorTabIniApp.class);
            act.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            act.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(act);
        }
    });

}

From source file:com.midooo.ui.activitys.ImageGridFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    layoutView = inflater.inflate(R.layout.ac_image_grid, null);

    //imageUrls = Constants.IMAGES;
    options = Constants.options;//w  w  w. j  a va 2  s .  c  om

    mPullRefreshGridView = (PullToRefreshGridView) layoutView.findViewById(R.id.pull_refresh_grid);

    mGridView = mPullRefreshGridView.getRefreshableView();

    // Set a listener to be invoked when the list should be refreshed.
    mPullRefreshGridView.setOnRefreshListener(new OnRefreshListener2<GridView>() {
        FaXingQuanMainActivity fca = (FaXingQuanMainActivity) getActivity();

        @Override
        public void onPullDownToRefresh(PullToRefreshBase<GridView> refreshView) {
            Toast.makeText(fca, "Pull Down!", Toast.LENGTH_SHORT).show();
            new GetDataTask().execute();
        }

        @Override
        public void onPullUpToRefresh(PullToRefreshBase<GridView> refreshView) {
            Toast.makeText(fca, "Pull Up!", Toast.LENGTH_SHORT).show();
            new GetDataTask().execute();
        }

    });

    //Looper looper = Looper.myLooper();
    //messageHandler = new MessageHandler(looper);

    /*
          mAdapter = new ImageAdapter();
          mGridView.setAdapter(mAdapter);
          mGridView.setOnItemClickListener(new OnItemClickListener() {
             @Override
             public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    //startImagePagerActivity(position);
    Log.w("---doop---", "startImagePagerActivity(position)");
             }
          });
    */

    /*
    ((GridView) listView).setAdapter(new ImageAdapter(inflater));
    listView.setOnItemClickListener(new OnItemClickListener() {
       @Override
       public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    //startImagePagerActivity(position);
    Log.w("---doop---", "startImagePagerActivity(position)");
       }
    });
    */

    return layoutView;
}