Java 类android.widget.TwoLineListItem 实例源码

项目:klingon-assistant    文件:KlingonAssistant.java   
@Override
public View getView(int position, View convertView, ViewGroup parent) {
  TwoLineListItem view =
      (convertView != null) ? (TwoLineListItem) convertView : createView(parent);
  mCursor.moveToPosition(position);
  bindView(view, mCursor);
  return view;
}
项目:klingon-assistant    文件:KlingonAssistant.java   
private TwoLineListItem createView(ViewGroup parent) {
  TwoLineListItem item =
      (TwoLineListItem) mInflater.inflate(android.R.layout.simple_list_item_2, parent, false);

  // Set single line to true if you want shorter definitions.
  item.getText2().setSingleLine(false);
  item.getText2().setEllipsize(TextUtils.TruncateAt.END);

  return item;
}
项目:klingon-assistant    文件:KlingonAssistant.java   
private void bindView(TwoLineListItem view, Cursor cursor) {
  KlingonContentProvider.Entry entry =
      new KlingonContentProvider.Entry(cursor, getBaseContext());

  // Note that we override the typeface and text size here, instead of in
  // the xml, because putting it there would also change the appearance of
  // the Preferences page. We fully indent suffixes, but only half-indent verbs.
  String indent1 =
      entry.isIndented() ? (entry.isVerb() ? "  " : "    ") : "";
  String indent2 =
      entry.isIndented()
          ? (entry.isVerb()
              ? "    "
              : "       ")
          : "";

  SharedPreferences sharedPrefs =
      PreferenceManager.getDefaultSharedPreferences(getBaseContext());
  if (Preferences.useKlingonFont(getBaseContext())) {
    // Preference is set to display this in {pIqaD}!
    view.getText1().setTypeface(KlingonAssistant.getKlingonFontTypeface(getBaseContext()));
    view.getText1().setText(Html.fromHtml(indent1 + entry.getEntryNameInKlingonFont()));
  } else {
    // Use serif for the entry, so capital-I and lowercase-l are distinguishable.
    view.getText1().setTypeface(Typeface.SERIF);
    view.getText1()
        .setText(Html.fromHtml(indent1 + entry.getFormattedEntryName(/* isHtml */ true)));
  }
  view.getText1().setTextSize(22);

  // TODO: Colour attached affixes differently from verb.
  view.getText1().setTextColor(entry.getTextColor());

  // Use sans serif for the definition.
  view.getText2().setTypeface(Typeface.SANS_SERIF);
  view.getText2()
      .setText(Html.fromHtml(indent2 + entry.getFormattedDefinition(/* isHtml */ true)));
  view.getText2().setTextSize(14);
  view.getText2().setTextColor(0xFFC0C0C0);
}
项目:nexus-gallery    文件:GalleryActionBar.java   
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        convertView = mInflater.inflate(R.layout.action_bar_two_line_text,
                parent, false);
    }
    TwoLineListItem view = (TwoLineListItem) convertView;
    view.getText1().setText(mActionBar.getTitle());
    view.getText2().setText((CharSequence) getItem(position));
    return convertView;
}
项目:PowerDoctor    文件:SaveInformationActivity.java   
@Override
protected void bindGroupView(View view, Context context, Cursor cursor,
        boolean isExpanded) {
    // TODO Auto-generated method stub  
    TwoLineListItem mTwoLineList = (TwoLineListItem)view;
    TextView mInfoView = mTwoLineList.getText1();
    TextView mInfoView2 = mTwoLineList.getText2();

    mInfoView.setTextSize(15);
    mInfoView.setTextColor(Color.GREEN);
    mInfoView2.setTextSize(15);
    mInfoView2.setTextColor(Color.BLUE);
    mInfoView.setText(cursor.getString(_ID)+" Power: "+cursor.getString(POWER)+"mW");
    mInfoView2.setText(" Range:\t"+cursor.getString(STARTPOINT)+"% ~ "+cursor.getString(ENDPOINT)+"%");
}
项目:DroidMeter    文件:MainActivity.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mUsbManager = (UsbManager) getSystemService(Context.USB_SERVICE);
    mListView = (ListView) findViewById(R.id.deviceList);
    mProgressBar = (ProgressBar) findViewById(R.id.progressBar);
    mProgressBarTitle = (TextView) findViewById(R.id.progressBarTitle);

    mAdapter = new ArrayAdapter<UsbSerialPort>(this,
            android.R.layout.simple_expandable_list_item_2, mEntries) {
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            final TwoLineListItem row;
            if (convertView == null){
                final LayoutInflater inflater =
                        (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                row = (TwoLineListItem) inflater.inflate(android.R.layout.simple_list_item_2, null);
            } else {
                row = (TwoLineListItem) convertView;
            }

            final UsbSerialPort port = mEntries.get(position);
            final UsbSerialDriver driver = port.getDriver();
            final UsbDevice device = driver.getDevice();

            final String title = String.format("Vendor %s Product %s",
                    HexDump.toHexString((short) device.getVendorId()),
                    HexDump.toHexString((short) device.getProductId()));
            row.getText1().setText(title);

            final String subtitle = driver.getClass().getSimpleName();
            row.getText2().setText(subtitle);

            return row;
        }

    };
    mListView.setAdapter(mAdapter);

    mListView.setOnItemClickListener(new ListView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Log.d(TAG, "Pressed item " + position);
            if (position >= mEntries.size()) {
                Log.w(TAG, "Illegal position.");
                return;
            }

            final UsbSerialPort port = mEntries.get(position);
            showConsoleActivity(port);
        }
    });
}
项目:Pancakes    文件:ViewStackTest.java   
private void assertTopViewIsCorrectType() {
    assertTrue(container.getChildAt(1) instanceof TwoLineListItem);
}
项目:android-vusb-arduino    文件:DeviceListActivity.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    mUsbManager = (UsbManager) getSystemService(Context.USB_SERVICE);
    mListView = (ListView) findViewById(R.id.deviceList);
    mProgressBar = (ProgressBar) findViewById(R.id.progressBar);
    mProgressBarTitle = (TextView) findViewById(R.id.progressBarTitle);

    mAdapter = new ArrayAdapter<UsbSerialPort>(this,
            android.R.layout.simple_expandable_list_item_2, mEntries) {
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            final TwoLineListItem row;
            if (convertView == null){
                final LayoutInflater inflater =
                        (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                row = (TwoLineListItem) inflater.inflate(android.R.layout.simple_list_item_2, null);
            } else {
                row = (TwoLineListItem) convertView;
            }

            final UsbSerialPort port = mEntries.get(position);
            final UsbSerialDriver driver = port.getDriver();
            final UsbDevice device = driver.getDevice();

            final String title = String.format("Vendor %s Product %s",
                    HexDump.toHexString((short) device.getVendorId()),
                    HexDump.toHexString((short) device.getProductId()));
            row.getText1().setText(title);

            final String subtitle = driver.getClass().getSimpleName();
            row.getText2().setText(subtitle);

            return row;
        }

    };
    mListView.setAdapter(mAdapter);

    mListView.setOnItemClickListener(new ListView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Log.d(TAG, "Pressed item " + position);
            if (position >= mEntries.size()) {
                Log.w(TAG, "Illegal position.");
                return;
            }

            final UsbSerialPort port = mEntries.get(position);
            showConsoleActivity(port);
        }
    });
}
项目:drone    文件:DeviceListActivity.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    mUsbManager = (UsbManager) getSystemService(Context.USB_SERVICE);
    mListView = (ListView) findViewById(R.id.deviceList);
    mProgressBar = (ProgressBar) findViewById(R.id.progressBar);
    mProgressBarTitle = (TextView) findViewById(R.id.progressBarTitle);

    mAdapter = new ArrayAdapter<UsbSerialPort>(this,
            android.R.layout.simple_expandable_list_item_2, mEntries) {
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            final TwoLineListItem row;
            if (convertView == null){
                final LayoutInflater inflater =
                        (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                row = (TwoLineListItem) inflater.inflate(android.R.layout.simple_list_item_2, null);
            } else {
                row = (TwoLineListItem) convertView;
            }

            final UsbSerialPort port = mEntries.get(position);
            final UsbSerialDriver driver = port.getDriver();
            final UsbDevice device = driver.getDevice();

            final String title = String.format("Vendor %s Product %s",
                    HexDump.toHexString((short) device.getVendorId()),
                    HexDump.toHexString((short) device.getProductId()));
            row.getText1().setText(title);

            final String subtitle = driver.getClass().getSimpleName();
            row.getText2().setText(subtitle);

            return row;
        }

    };
    mListView.setAdapter(mAdapter);

    mListView.setOnItemClickListener(new ListView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Log.d(TAG, "Pressed item " + position);
            if (position >= mEntries.size()) {
                Log.w(TAG, "Illegal position.");
                return;
            }

            final UsbSerialPort port = mEntries.get(position);
            showConsoleActivity(port);
        }
    });
}
项目:usb-serial-for-android    文件:DeviceListActivity.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    mUsbManager = (UsbManager) getSystemService(Context.USB_SERVICE);
    mListView = (ListView) findViewById(R.id.deviceList);
    mProgressBar = (ProgressBar) findViewById(R.id.progressBar);
    mProgressBarTitle = (TextView) findViewById(R.id.progressBarTitle);

    mAdapter = new ArrayAdapter<UsbSerialPort>(this,
            android.R.layout.simple_expandable_list_item_2, mEntries) {
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            final TwoLineListItem row;
            if (convertView == null){
                final LayoutInflater inflater =
                        (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                row = (TwoLineListItem) inflater.inflate(android.R.layout.simple_list_item_2, null);
            } else {
                row = (TwoLineListItem) convertView;
            }

            final UsbSerialPort port = mEntries.get(position);
            final UsbSerialDriver driver = port.getDriver();
            final UsbDevice device = driver.getDevice();

            final String title = String.format("Vendor %s Product %s",
                    HexDump.toHexString((short) device.getVendorId()),
                    HexDump.toHexString((short) device.getProductId()));
            row.getText1().setText(title);

            final String subtitle = driver.getClass().getSimpleName();
            row.getText2().setText(subtitle);

            return row;
        }

    };
    mListView.setAdapter(mAdapter);

    mListView.setOnItemClickListener(new ListView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Log.d(TAG, "Pressed item " + position);
            if (position >= mEntries.size()) {
                Log.w(TAG, "Illegal position.");
                return;
            }

            final UsbSerialPort port = mEntries.get(position);
            showConsoleActivity(port);
        }
    });
}
项目:Pancakes    文件:ViewStackTest.java   
@Test
public void peek() {
    viewStack.push(BOTTOM_LAYOUT_RES);

    viewStack.push(TOP_LAYOUT_RES);

    View view = viewStack.peek();

    assertTrue(view instanceof TwoLineListItem);
}