@Override
 public View getView(int position, View convertView, ViewGroup parent) {
   View v = convertView;
   if (v == null) {
     LayoutInflater vi =
         (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
     v = vi.inflate(R.layout.row, null);
   }
   Message m = items.get(position);
   // if (m != null) {
   m.createColorFromString(m.from);
   TextView tt = (TextView) v.findViewById(R.id.username);
   TextView bt = (TextView) v.findViewById(R.id.message);
   if (isMonospaced) {
     tt.setTypeface(Typeface.MONOSPACE);
     bt.setTypeface(Typeface.MONOSPACE);
   }
   tt.setText(m.getFrom());
   tt.setTextColor(m.color);
   bt.setText(m.getMessage());
   // }
   return v;
 }
 private View getFooterView() {
   if (mFooterView == null) {
     FrameLayout fl = new FrameLayout(getActivity());
     TextView tv = new TextView(getActivity());
     tv.setGravity(Gravity.CENTER);
     tv.setTextColor(0xFFaaaaaa);
     tv.setBackgroundColor(0xFFffffff);
     FrameLayout.LayoutParams params =
         new FrameLayout.LayoutParams(
             ViewGroup.LayoutParams.MATCH_PARENT, (int) CommonUtils.dpToPx(getActivity(), 50));
     fl.addView(tv, params);
     mFooterView = fl;
   }
   TextView tv = (TextView) mFooterView.getChildAt(0);
   tv.setText("共有" + SongManager.with(getActivity()).getSongSize() + "首歌");
   return mFooterView;
 }
示例#3
0
  private void SetBackGroundforList() {
    // TODO Auto-generated method stub
    mDownView_parent_txt1 = new TextView(activity.getApplicationContext());
    RelativeLayout.LayoutParams lp1 =
        new RelativeLayout.LayoutParams(
            LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    lp1.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    mDownView_parent_txt1.setId(Integer.parseInt("111111"));
    mDownView_parent_txt1.setLayoutParams(lp1);
    mDownView_parent_txt1.setGravity(Gravity.CENTER_HORIZONTAL);
    mDownView_parent_txt1.setText(HalfText);
    mDownView_parent_txt1.setWidth(textwidth2);
    mDownView_parent_txt1.setPadding(0, textheight / 4, 0, 0);
    mDownView_parent_txt1.setHeight(textheight);
    mDownView_parent_txt1.setBackgroundColor(Color.parseColor(FullColor));
    mDownView_parent_txt1.setTextColor(Color.parseColor(TextColor));
    mDownView_parent_txt1.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
    mDownView_parent.addView(mDownView_parent_txt1, 0);

    //         if(SwipeType==Double){
    //             mDownView_parent_txt2 = new TextView(activity.getApplicationContext());
    //             mDownView_parent_txt2.setId(222222);
    //             RelativeLayout.LayoutParams lp2 =new
    // RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT);
    //             lp2.addRule(RelativeLayout.LEFT_OF,mDownView_parent_txt1.getId());
    //             mDownView_parent_txt2.setLayoutParams(lp2);
    //             mDownView_parent_txt2.setGravity(Gravity.CENTER_HORIZONTAL);
    //             mDownView_parent_txt2.setText(FullText);
    //             mDownView_parent_txt2.setWidth(textwidth);
    //             mDownView_parent_txt2.setPadding(0, textheight/4, 0, 0);
    //             mDownView_parent_txt2.setHeight(textheight);
    //             mDownView_parent_txt2.setBackgroundColor(Color.parseColor(FullColor));
    //             mDownView_parent_txt2.setTextColor(Color.parseColor(TextColor));
    //             mDownView_parent_txt2.setCompoundDrawablesWithIntrinsicBounds(null ,
    // FullDrawable, null, null );
    //             mDownView_parent.addView(mDownView_parent_txt2, 1);
    //         }
  }
示例#4
0
  @Override
  public View GetView(
      LayoutInflater inflater,
      ViewGroup container,
      SurveyActivity activityRef,
      SurveyAdapter surveyAdapter,
      int parentId) {

    View view = inflater.inflate(R.layout.gps_question, container, false);
    TextView label = (TextView) view.findViewById(R.id.description);
    label.setText(this.label);
    label.setTextSize(fontSize);

    Typeface tf = Typeface.createFromAsset(activityRef.getAssets(), "fonts/OpenSans-Regular.ttf");
    label.setTypeface(tf);

    try {
      label.setTextColor(Color.parseColor(color));
    } catch (Exception e) {
    }

    // SET LABELS
    TextView textlatlabel = (TextView) view.findViewById(R.id.lattext);
    textlatlabel.setText(latLabel);
    textlatlabel.setTypeface(tf);

    TextView textLonlabel = (TextView) view.findViewById(R.id.lontext);
    textLonlabel.setText(lonLabel);
    textLonlabel.setTypeface(tf);

    // GET GPS POSITION
    textLat = (TextView) view.findViewById(R.id.latitude);
    textLon = (TextView) view.findViewById(R.id.longitude);
    textLat.setTypeface(tf);
    textLon.setTypeface(tf);

    if (locationManager == null) {
      // Acquire a reference to the system Location Manager
      locationManager =
          (LocationManager) view.getContext().getSystemService(Context.LOCATION_SERVICE);

      // Define a listener that responds to location updates
      LocationListener locationListener =
          new LocationListener() {
            public void onLocationChanged(Location location) {

              if (LocationUtil.isBetterLocation(location, currentBestLocation)) {
                // Called when a new location is found by the network location provider.
                textLat.setText(String.valueOf(location.getLatitude()));
                textLon.setText(String.valueOf(location.getLongitude()));
                answer =
                    String.valueOf(location.getLatitude())
                        + "/"
                        + String.valueOf(location.getLongitude());

                // Remove the listener you previously added
                locationManager.removeUpdates(this);
              }
            }

            public void onProviderEnabled(String provider) {}

            public void onProviderDisabled(String provider) {}

            @Override
            public void onStatusChanged(String provider, int status, Bundle extras) {
              // TODO Auto-generated method stub

            }
          };

      // Register the listener with the Location Manager to receive location updates
      locationManager.requestLocationUpdates(
          LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);
      locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);

      Criteria criteria = new Criteria();
      String provider = locationManager.getBestProvider(criteria, false);
      currentBestLocation = locationManager.getLastKnownLocation(provider);
    }

    // SET ORIENTATION
    LinearLayout layout = (LinearLayout) view.findViewById(R.id.layout);
    if (orientation.equals("horizontal")) layout.setOrientation(LinearLayout.HORIZONTAL);
    else layout.setOrientation(LinearLayout.VERTICAL);

    // SET ANSWER
    if (!answer.equals("")) {
      String[] parts = answer.split("/");
      textLat.setText(parts[0]);
      textLon.setText(parts[1]);
    }
    return view;
  }