Android Open Source - UltimateCom Tty Config Fragment






From Project

Back to project page UltimateCom.

License

The source code is released under:

GNU General Public License

If you think the Android project UltimateCom listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package org.ultimatecom;
//  w w  w  .j  a va2  s  . co  m
import org.ultimatecom.R;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.Button;
import android.widget.Spinner;

public class TtyConfigFragment extends Fragment {

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        final View view = inflater.inflate(R.layout.fragment_tty_config, container, false);
        
        final Button connectButton = (Button) view.findViewById(R.id.connect_button);
        connectButton.setEnabled(false);
        connectButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(getActivity(), TtyTransmissionActivity.class));
            }
        });
        
        final AutoCompleteTextView ttyPathTextView = (AutoCompleteTextView) view.findViewById(R.id.tty_path_text_view);
        ttyPathTextView.setAdapter(new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, new String[] { "/dev/ttyUSB0", "/dev/ttyUSB1" }));
        ttyPathTextView.addTextChangedListener(new TextWatcher() {
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                connectButton.setEnabled(ttyPathTextView.getText().length() > 0);
            }
            
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count,
                    int after) {
                connectButton.setEnabled(ttyPathTextView.getText().length() > 0);
            }
            
            @Override
            public void afterTextChanged(Editable s) {
                connectButton.setEnabled(ttyPathTextView.getText().length() > 0);
            }
        });
        
        final Spinner baudRateSpinner = (Spinner) view.findViewById(R.id.baud_rate_spinner);
        baudRateSpinner.setAdapter(new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_dropdown_item, new String[] { "19200", "38400" }));
        
        return view;
    }

}




Java Source Code List

org.ultimatecom.BluetoothConfigFragment.java
org.ultimatecom.BluetoothTransmissionActivity.java
org.ultimatecom.ConnectionConfigActivity.java
org.ultimatecom.IoioConfigFragment.java
org.ultimatecom.RingBufferCharSequence.java
org.ultimatecom.StreamTransmissionActivity.java
org.ultimatecom.TcpConfigFragment.java
org.ultimatecom.TransmissionActivity.java
org.ultimatecom.TtyConfigFragment.java
org.ultimatecom.TtyTransmissionActivity.java
org.ultimatecom.UsbSerialConfigFragment.java