/** * Adds one, two, or three buttons to the layout. * * @param primaryText Text for the primary button. * @param secondaryText Text for the secondary button, or null if there isn't a second button. * @param tertiaryText Text for the tertiary button, or null if there isn't a third button. */ public void setButtons(String primaryText, String secondaryText, String tertiaryText) { if (TextUtils.isEmpty(primaryText)) return; mPrimaryButton = new ButtonCompat(getContext(), mAccentColor); mPrimaryButton.setId(R.id.button_primary); mPrimaryButton.setOnClickListener(this); mPrimaryButton.setText(primaryText); mPrimaryButton.setTextColor(Color.WHITE); if (TextUtils.isEmpty(secondaryText)) return; mSecondaryButton = ButtonCompat.createBorderlessButton(getContext()); mSecondaryButton.setId(R.id.button_secondary); mSecondaryButton.setOnClickListener(this); mSecondaryButton.setText(secondaryText); mSecondaryButton.setTextColor(mAccentColor); if (TextUtils.isEmpty(tertiaryText)) return; mTertiaryButton = ButtonCompat.createBorderlessButton(getContext()); mTertiaryButton.setId(R.id.button_tertiary); mTertiaryButton.setOnClickListener(this); mTertiaryButton.setText(tertiaryText); mTertiaryButton.setPadding( mMargin / 2, mTertiaryButton.getPaddingTop(), mMargin / 2, mTertiaryButton.getPaddingBottom()); mTertiaryButton.setTextColor( ApiCompatibilityUtils.getColor( getContext().getResources(), R.color.infobar_tertiary_button_text)); }
private View createImageButton(int x, int y) { Button button = new Button(context); button.setBackgroundDrawable(backImage); button.setId(100 * x + y); button.setOnClickListener(buttonListener); return button; }
@Override public void displaySelf(ViewGroup parent) { // TODO: Accept view/layout but cast to viewgroup? Log.d(this.getClass().getSimpleName(), "parent: " + parent); Button button = (Button) parent.findViewById(WIDGET_ID_OFFSET + remoteWidgetId); if (button == null) { button = new Button(parent.getContext()); button.setId( WIDGET_ID_OFFSET + remoteWidgetId); // TODO: Make this use a function to get the ID? parent.addView(button); } configureAsTextView(button); button.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { // Perform action on click Log.d(this.getClass().getSimpleName(), "button click: " + remoteWidgetId); // TODO: Send response // TODO: Send properly rather than accessing activity method directly (or accept // callback tunnel from activity)? // TODO: Ensure not null? activity.sendPacket( new String[] { "widget", "event", Integer.toString(remoteWidgetId), "click" }); // TODO: Do properly. } }); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); DBHelper dbHelper = DBHelper.getInstance(getApplicationContext()); setContentView(R.layout.activity_buoc); LinearLayout gardenLayout = (LinearLayout) findViewById(R.id.gardenLayoutLinear); // create buttons to put inside linear layout int counter = 1; for (int rows = 0; rows < 10; rows++) { LinearLayout currentLinear = new LinearLayout(this); currentLinear.setOrientation(LinearLayout.HORIZONTAL); for (int cols = 0; cols < 3; cols++) { final Button currButton = new Button(this); LinearLayout.LayoutParams param; param = new LinearLayout.LayoutParams( Toolbar.LayoutParams.WRAP_CONTENT, Toolbar.LayoutParams.WRAP_CONTENT, 1.0f); currButton.setLayoutParams(param); currButton.setWidth(50); currButton.setHeight(125); currButton.setGravity(Gravity.CENTER); currButton.setId(counter); currButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { redirectToBedOptions(currButton); } }); currButton.setText("" + currButton.getId()); currentLinear.addView(currButton); counter++; } gardenLayout.addView(currentLinear); } // Grab the first five garden notes and display them in the notes section // for now we will mock up data to show. final ListView gardenNotePreviewList = (ListView) findViewById(R.id.gardenNotePreviewList); Note mock_up_data[] = null; try { mock_up_data = new Note[5]; mock_up_data[0] = new Note("Warning signs around garden", ""); mock_up_data[1] = new Note("Cleaned around garden.", ""); mock_up_data[2] = new Note("Created new Garden Worksheet.", ""); mock_up_data[3] = new Note("subject 4", ""); mock_up_data[4] = new Note("subject 5", ""); } catch (Exception ex) { ex.printStackTrace(); } GardenLayoutNotePreviewListAdapter adapter = new GardenLayoutNotePreviewListAdapter(this, R.layout.custom_garden_note, mock_up_data); gardenNotePreviewList.setAdapter(adapter); }
public void onClick(View v) { switch (v.getId()) { case R.id.btnAddPeople: final TableRow tr = new TableRow(this); tr.setId(1); EditText editText = new EditText(this); editText.setId(200); editText.setInputType(InputType.TYPE_TEXT_VARIATION_PERSON_NAME); editText.setMinWidth(100); // labelTV.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, // LayoutParams.WRAP_CONTENT)); tr.addView(editText); editText.requestFocus(); Button deleteButton = new Button(this); deleteButton.setBackgroundDrawable(getResources().getDrawable(R.drawable.delete)); deleteButton.setId(200); deleteButton.setOnClickListener( new OnClickListener() { public void onClick(View v) { tblPersons.removeView(tr); } }); tr.addView(deleteButton); tblPersons.addView(tr); break; case R.id.btnContinue: String names = ""; for (int i = 0; i < tblPersons.getChildCount(); i++) { TableRow row = (TableRow) tblPersons.getChildAt(i); String name = ((EditText) (row.getChildAt(0))).getText().toString(); if (name != null && name.trim() != "") { names = names + name.trim(); } if (i < tblPersons.getChildCount() - 1) { names = names + ","; } } System.out.println("!!!!!!!!!!names:" + names); Intent intentExpenses = new Intent(); intentExpenses.setClassName("com.expenses", "com.expenses.ExpensesShareActivity"); intentExpenses.putExtra("com.expenses.PersonNames", names); startActivity(intentExpenses); break; default: break; } }
private Button createButton(int id, String text) { Button btn = new Button(this); btn.setId(id); btn.setText(text); btn.setMinWidth(dp2px(50)); btn.setMaxWidth(dp2px(120)); btn.setOnClickListener(this); return btn; }
public void addItem(String s, int i, int j, int k) { ViewGroup viewgroup = mRoot; Button button = (Button)LayoutInflater.from(viewgroup.getContext()).inflate(mButtonResource, viewgroup, false); button.setId(j); button.setText(s); button.setOnClickListener(mListener); viewgroup.addView(button); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); LinearLayout linLayout = new LinearLayout(this); Button requestButton = new Button(this); requestButton.setOnClickListener(this); requestButton.setId(R.id.requestQueue); requestButton.setText(R.string.sync_pending_requests); Button resetButton = new Button(this); resetButton.setOnClickListener(this); resetButton.setId(R.id.resetDatabase); resetButton.setText(R.string.settings_reset_database); linLayout.addView(requestButton); linLayout.addView(resetButton); setListFooter(linLayout); }
public Button createListPageButton( Activity paramActivity, Map<String, Object> paramMap, String paramString, int paramInt) { Button localButton = new Button(paramActivity); localButton.setId(paramInt); localButton.setTag(Integer.valueOf(5)); localButton.setText(paramString); localButton.setGravity(17); localButton.setPadding(3, 0, 3, 0); return localButton; }
private View onCreateContextView() { RelativeLayout root = new RelativeLayout(this); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT); root.setLayoutParams(params); Button button01 = new Button(this); params = new RelativeLayout.LayoutParams( DipUtils.getInstance().fromMediumDensityPixel(100), DipUtils.getInstance().fromMediumDensityPixel(100)); button01.setLayoutParams(params); button01.setId(ID_BUTTON01); button01.setText("fromMedium 100px"); Button button02 = new Button(this); params = new RelativeLayout.LayoutParams( DipUtils.getInstance().fromHightDensityPixel(100), DipUtils.getInstance().fromHightDensityPixel(100)); params.addRule(RelativeLayout.RIGHT_OF, ID_BUTTON01); button02.setLayoutParams(params); button02.setId(ID_BUTTON02); button02.setText("fromHight 100px"); Button button03 = new Button(this); params = new RelativeLayout.LayoutParams( DipUtils.getInstance().fromLowDensityPixel(100), DipUtils.getInstance().fromLowDensityPixel(100)); params.addRule(RelativeLayout.RIGHT_OF, ID_BUTTON02); button03.setId(ID_BUTTON03); button03.setLayoutParams(params); button03.setText("fromLow 100px"); root.addView(button01); root.addView(button02); root.addView(button03); return root; }
/** * Creates and returns a button used to add non-click buttons to keyboard * * @param sym * @param i * @return */ private Button createButton(String sym, int i, OnClickListener listener) { Button btn = new Button(this); final Button button = btn; final String symbol = new String(sym + ""); btn.setOnClickListener(createListener(button, symbol)); btn.setId(i); btn.setTypeface(null, Typeface.BOLD); btn.setBackgroundResource(R.drawable.small_button); btn.setTextColor(Color.parseColor("#ffffff")); btn.setText(sym); return btn; }
public BearingWidget(Context context, FormEntryPrompt prompt) { super(context, prompt); setOrientation(LinearLayout.VERTICAL); TableLayout.LayoutParams params = new TableLayout.LayoutParams(); params.setMargins(7, 5, 7, 5); mGetBearingButton = new Button(getContext()); mGetBearingButton.setId(QuestionWidget.newUniqueId()); mGetBearingButton.setPadding(20, 20, 20, 20); mGetBearingButton.setText(getContext().getString(R.string.get_bearing)); mGetBearingButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mAnswerFontsize); mGetBearingButton.setEnabled(!prompt.isReadOnly()); mGetBearingButton.setLayoutParams(params); if (prompt.isReadOnly()) { mGetBearingButton.setVisibility(View.GONE); } mStringAnswer = new TextView(getContext()); mStringAnswer.setId(QuestionWidget.newUniqueId()); mAnswerDisplay = new TextView(getContext()); mAnswerDisplay.setId(QuestionWidget.newUniqueId()); mAnswerDisplay.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mAnswerFontsize); mAnswerDisplay.setGravity(Gravity.CENTER); String s = prompt.getAnswerText(); if (s != null && !s.equals("")) { mGetBearingButton.setText(getContext().getString(R.string.replace_bearing)); setBinaryData(s); } // when you press the button mGetBearingButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Collect.getInstance() .getActivityLogger() .logInstanceAction(this, "recordBearing", "click", mPrompt.getIndex()); Intent i = null; i = new Intent(getContext(), BearingActivity.class); Collect.getInstance().getFormController().setIndexWaitingForData(mPrompt.getIndex()); ((Activity) getContext()).startActivityForResult(i, FormEntryActivity.BEARING_CAPTURE); } }); addView(mGetBearingButton); addView(mAnswerDisplay); }
@Override public View getView(int position, View convertView, ViewGroup parent) { MenuEntry me = m_menu.m_arItems.get(position); if (convertView != null) { Button b = (Button) convertView; b.setTag(me); b.setId(me.id); b.setText(me.text); } else { convertView = m_menu.newView(me); } return convertView; }
/** @param context */ public ChapterView(Context context, Book bok, BookViewController controller) { super(context); // TODO Auto-generated constructor stub mContext = context; this.book = bok; mBookViewController = controller; display = ((Activity) context).getWindowManager().getDefaultDisplay(); setBackgroundColor(Color.WHITE); prefsManager = new PrefsManager(mContext); hasHistory = prefsManager.hashistory(); int btnWidth = display.getWidth() / 2; layout = new LinearLayout(context); layout.setOrientation(LinearLayout.VERTICAL); layout.setGravity(Gravity.CENTER_HORIZONTAL); continuBtn = new Button(context); continuBtn.setId(0); continuBtn.setText("¼ÌÐøÉÏ´ÎÔĶÁ"); continuBtn.setOnClickListener(this); continuBtn.setEnabled(hasHistory); layout.addView(continuBtn, LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); for (int i = 0; i < book.getFlatNavPoints().size(); i++) { NavPoint np = book.getFlatNavPoints().get(i); Button b = new Button(context); b.setId(i + 1); b.setText(np.getLabel()); b.setWidth(btnWidth); b.setOnClickListener(this); layout.addView(b, LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); } addView(layout); }
public UrlWidget(Context context, FormEntryPrompt prompt) { super(context, prompt); setOrientation(LinearLayout.VERTICAL); TableLayout.LayoutParams params = new TableLayout.LayoutParams(); params.setMargins(7, 5, 7, 5); // set button formatting mOpenUrlButton = new Button(getContext()); mOpenUrlButton.setId(QuestionWidget.newUniqueId()); mOpenUrlButton.setText(getContext().getString(R.string.open_url)); mOpenUrlButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mAnswerFontsize); mOpenUrlButton.setPadding(20, 20, 20, 20); mOpenUrlButton.setEnabled(!prompt.isReadOnly()); mOpenUrlButton.setLayoutParams(params); mOpenUrlButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Collect.getInstance() .getActivityLogger() .logInstanceAction(this, "openUrl", "click", mPrompt.getIndex()); if (mStringAnswer != null & mStringAnswer.getText() != null && !"".equalsIgnoreCase((String) mStringAnswer.getText())) { Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse((String) mStringAnswer.getText())); getContext().startActivity(i); } else { Toast.makeText(getContext(), "No URL set", Toast.LENGTH_SHORT).show(); } } }); // set text formatting mStringAnswer = new TextView(getContext()); mStringAnswer.setId(QuestionWidget.newUniqueId()); mStringAnswer.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mAnswerFontsize); mStringAnswer.setGravity(Gravity.CENTER); String s = prompt.getAnswerText(); if (s != null) { mStringAnswer.setText(s); } // finish complex layout addView(mOpenUrlButton); addView(mStringAnswer); }
private boolean addNeutralButton(ViewGroup parent, boolean addDivider) { if (mNeutralButtonText != null) { if (addDivider) { addDivider(parent); } Button btn = (Button) mInflater.inflate(R.layout.dialog_part_button, parent, false); btn.setId(R.id.sdl__neutral_button); btn.setText(mNeutralButtonText); btn.setTextColor(mButtonTextColor); btn.setBackgroundDrawable(getButtonBackground()); btn.setOnClickListener(mNeutralButtonListener); parent.addView(btn); return true; } return addDivider; }
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); LinearLayout layout = new LinearLayout(this); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(250, 50); layout.setOrientation(LinearLayout.VERTICAL); btn1 = new Button(this); btn1.setId(101); btn1.setText("message from main thread self"); btn1.setOnClickListener(this); layout.addView(btn1, params); btn2 = new Button(this); btn2.setId(102); btn2.setText("message from other thread to main thread"); btn2.setOnClickListener(this); layout.addView(btn2, params); btn3 = new Button(this); btn3.setId(103); btn3.setText("message to other thread from itself"); btn3.setOnClickListener(this); layout.addView(btn3, params); btn4 = new Button(this); btn4.setId(104); btn4.setText("message with Runnable as callback from other thread to main thread"); btn4.setOnClickListener(this); layout.addView(btn4, params); btn5 = new Button(this); btn5.setId(105); btn5.setText("main thread's message to other thread"); btn5.setOnClickListener(this); layout.addView(btn5, params); btn6 = new Button(this); btn6.setId(106); btn6.setText("exit"); btn6.setOnClickListener(this); layout.addView(btn6, params); tv = new TextView(this); tv.setTextColor(Color.WHITE); tv.setText(""); params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); params.topMargin = 10; layout.addView(tv, params); setContentView(layout); receiveMessageThread = new ReceiveMessageThread(); receiveMessageThread.start(); }
public ExPrinterWidget(Context context, FormEntryPrompt prompt) { super(context, prompt); TableLayout.LayoutParams params = new TableLayout.LayoutParams(); params.setMargins(7, 5, 7, 5); String appearance = prompt.getAppearanceHint(); String[] attrs = appearance.split(":"); final String intentName = (attrs.length < 2 || attrs[1].length() == 0) ? "org.opendatakit.sensors.ZebraPrinter" : attrs[1]; final String buttonText; final String errorString; String v = mPrompt.getSpecialFormQuestionText("buttonText"); buttonText = (v != null) ? v : context.getString(R.string.launch_printer); v = mPrompt.getSpecialFormQuestionText("noPrinterErrorString"); errorString = (v != null) ? v : context.getString(R.string.no_printer); // set button formatting mLaunchIntentButton = new Button(getContext()); mLaunchIntentButton.setId(QuestionWidget.newUniqueId()); mLaunchIntentButton.setText(buttonText); mLaunchIntentButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mAnswerFontsize); mLaunchIntentButton.setPadding(20, 20, 20, 20); mLaunchIntentButton.setLayoutParams(params); mLaunchIntentButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { try { Collect.getInstance().getFormController().setIndexWaitingForData(mPrompt.getIndex()); firePrintingActivity(intentName); } catch (ActivityNotFoundException e) { Collect.getInstance().getFormController().setIndexWaitingForData(null); Toast.makeText(getContext(), errorString, Toast.LENGTH_SHORT).show(); } } }); // finish complex layout addView(mLaunchIntentButton); }
private void InitButton() { FrameLayout layout = (FrameLayout) view.findViewById(R.id.container); oval = new View(context); oval.setBackgroundResource(R.drawable.oval); layout.addView(oval); spinner = (Spinner) view.findViewById(R.id.spinner); arrStage = new String[stageList.length]; for (int i = 0; i < stageList.length; i++) { arrStage[i] = new String(stageList[i].stageName); for (int j = 0; j < stageList[i].nodeList.length; j++) { for (int k = 0; k < stageList[i].nodeList[j].deviceList.length; k++) { Button curButton = new Button(context); curButton.setBackgroundResource(R.drawable.focus_false); FrameLayout.LayoutParams imagebtn_params = new FrameLayout.LayoutParams(60, 80); imagebtn_params.leftMargin = GetX(stageList[i].nodeList[j].deviceList[k].px); imagebtn_params.topMargin = GetY(stageList[i].nodeList[j].deviceList[k].py); curButton.setId(i * 1000 + j * 100 + k); curButton.setLayoutParams(imagebtn_params); layout.addView(curButton); curButton.setOnClickListener(new deviceButtonListener()); if (i == curStage) curButton.setVisibility(View.VISIBLE); else curButton.setVisibility(View.GONE); } } } ArrayAdapter<String> adapter = new ArrayAdapter<String>(context, R.layout.spinner_board, arrStage) { @Override public View getDropDownView(int position, View convertView, ViewGroup parent) { View adapterView = getActivity().getLayoutInflater().inflate(R.layout.spinner_item, parent, false); TextView label = (TextView) adapterView.findViewById(R.id.label); label.setText(getItem(position)); ImageView icon = (ImageView) adapterView.findViewById(R.id.icon); icon.setVisibility( spinner.getSelectedItemPosition() == position ? View.VISIBLE : View.INVISIBLE); return adapterView; } }; adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); spinner.setOnItemSelectedListener(new stageOnItemSelectedListener()); }
// create a new ImageView for each item referenced by the Adapter public View getView(int position, View convertView, ViewGroup parent) { // ImageView imageView; Button tempBut; int multiple; String spinnerarray[]; spinnerarray = new String[4]; spinnerarray[0] = "1x"; spinnerarray[1] = "2x"; spinnerarray[2] = "3x"; spinnerarray[3] = "5x"; if (convertView == null) { // if it's not recycled, initialize some attributes tempBut = new Button(mContext); tempBut.setLayoutParams( new GridView.LayoutParams(DigitDexterityActivity.bsize, DigitDexterityActivity.bsize)); tempBut.setOnClickListener(mOnButtonClick); tempBut.setPadding(8, 8, 8, 8); } else { tempBut = (Button) convertView; } tempBut.setId(1000 + DigitDexterityActivity.location[position]); multiple = spinnerarray[((int) Preference.getMultiples(mContext).charAt(0)) - 48].charAt(0) - 48; if (DigitDexterityActivity.butenable[DigitDexterityActivity.location[position]] == 0) { tempBut.setEnabled(false); } else { tempBut.setEnabled(true); } if (Preference.getRoman(mContext)) { tempBut.setText( DigitDexterityActivity.romans[ (DigitDexterityActivity.location[position] + 1) * multiple]); } else { tempBut.setText(Integer.toString((DigitDexterityActivity.location[position] + 1) * multiple)); } tempBut.setTypeface(null, Typeface.BOLD); tempBut.setTextSize(20); return tempBut; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // layout RelativeLayout relativeLayout = new RelativeLayout(this); relativeLayout.setBackgroundColor(Color.GREEN); // button Button button = new Button(this); button.setText("Click Me !!"); button.setBackgroundColor(Color.RED); // Username Input EditText username = new EditText(this); button.setId(1); username.setId(2); RelativeLayout.LayoutParams buttonDetails = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); buttonDetails.addRule(RelativeLayout.CENTER_HORIZONTAL); buttonDetails.addRule(RelativeLayout.CENTER_VERTICAL); Resources r = getResources(); int px = (int) TypeValue.applyDimensions(TypedValue.COMPLEX_MANTISSA_DIP, 200, r.getDisplayMetrics()); username.setWidth(px); RelativeLayout.LayoutParams usernameDetails = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); usernameDetails.addRule(RelativeLayout.CENTER_HORIZONTAL); usernameDetails.addRule(RelativeLayout.CENTER_VERTICAL); // relativeLayout.addView(button, buttonDetails); setContentView(relativeLayout); }
private void createLayoutDynamically(int n) { for (int i = 0; i < n; i++) { Button myButton = new Button(this); myButton.setText("Button :" + i); myButton.setId(i); final int id_ = myButton.getId(); LinearLayout layout = (LinearLayout) findViewById(R.id.myLayoutId); layout.addView(myButton); myButton.setOnClickListener( new View.OnClickListener() { public void onClick(View view) { Toast.makeText(view.getContext(), "Button clicked index = " + id_, Toast.LENGTH_SHORT) .show(); } }); } }
@Override public View getView(int position, View convertView, ViewGroup parent) { Button button; if (convertView == null) { button = new Button(ctx); button.setText("" + (data[position])); } else { button = (Button) convertView; } if (position >= levelMax) { button.setEnabled(false); button.setAlpha(0.5f); } button.setId(data[position]); button.setTextSize(diametr * 0.2f); button.setWidth(diametr); button.setHeight(diametr); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { button.setBackground( ctx.getApplicationContext().getResources().getDrawable(R.drawable.button_sm)); } button.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { int lv = v.getId(); Intent intent = new Intent(ctx, GameActivity.class); SharedPreferences spref = ctx.getSharedPreferences("MyPref", Context.MODE_PRIVATE); SharedPreferences.Editor ed = spref.edit(); ed.putInt("Level", lv); ed.putBoolean("start", true); for (int i = 1; i <= 4; i++) { ed.putInt("figure" + i + "position", 0); ed.putInt("figure" + i + "rotation", 1); } ed.commit(); ctx.startActivity(intent); } }); return button; }
@Override public void onClick(View v) { // TextView tView = new TextView(Test_ScrollView.this);//定义一个TextView // tView.setText("TextView" + index);//设置TextView的文本信息 // 设置线性布局的属性 LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); // mLayout.addView(tView, params);//添加一个TextView控件. Button button = new Button(ScrollViewActivity.this); // 定义一个Button button.setText("Button" + index); // 设置Button的文本信息 button.setOnClickListener(mClickListener); // 添加点击事件监听. button.setId(index++); PieChart chart = new PieChart(ScrollViewActivity.this); // PieChat entry = new PieChat(ScrollViewActivity.this); mLayout.addView(button, params); // 添加一个Button控件 mLayout.addView(chart); mHandler.post(mScrollToButton); // 传递一个消息进行滚动. }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.choosefighter); model = (Model) getIntent().getSerializableExtra("Model"); LinearLayout linearLayout = (LinearLayout) this.findViewById(R.id.chooseFighter); int i = 0; for (Tacticien tacticien : model.getPlayer().getTacticiens()) { Button button = new Button(this); if (model.getPlayer().fintTacticien(tacticien)) { button.setEnabled(false); } button.setText("" + tacticien); button.setId(i); button.setOnClickListener( new View.OnClickListener() { public void onClick(final View v) { selectCharcter(v); } }); linearLayout.addView(button); i++; } Button back = new Button(this); back.setText("back"); back.setOnClickListener( new View.OnClickListener() { public void onClick(final View v) { backFormation(v); } }); linearLayout.addView(back); }
public SignatureWidget(Context context, FormEntryPrompt prompt) { super(context, prompt); mInstanceFolder = Collect.getInstance().getFormController().getInstancePath().getParent(); setOrientation(LinearLayout.VERTICAL); TableLayout.LayoutParams params = new TableLayout.LayoutParams(); params.setMargins(7, 5, 7, 5); mErrorTextView = new TextView(context); mErrorTextView.setId(QuestionWidget.newUniqueId()); mErrorTextView.setText("Selected file is not a valid image"); // setup Blank Image Button mSignButton = new Button(getContext()); mSignButton.setId(QuestionWidget.newUniqueId()); mSignButton.setText(getContext().getString(R.string.sign_button)); mSignButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mAnswerFontsize); mSignButton.setPadding(20, 20, 20, 20); mSignButton.setEnabled(!prompt.isReadOnly()); mSignButton.setLayoutParams(params); // launch capture intent on click mSignButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Collect.getInstance() .getActivityLogger() .logInstanceAction(this, "signButton", "click", mPrompt.getIndex()); launchSignatureActivity(); } }); // finish complex layout addView(mSignButton); addView(mErrorTextView); // and hide the sign button if read-only if (prompt.isReadOnly()) { mSignButton.setVisibility(View.GONE); } mErrorTextView.setVisibility(View.GONE); // retrieve answer from data model and update ui mBinaryName = prompt.getAnswerText(); // Only add the imageView if the user has signed if (mBinaryName != null) { mImageView = new ImageView(getContext()); mImageView.setId(QuestionWidget.newUniqueId()); Display display = ((WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE)) .getDefaultDisplay(); int screenWidth = display.getWidth(); int screenHeight = display.getHeight(); File f = new File(mInstanceFolder + File.separator + mBinaryName); if (f.exists()) { Bitmap bmp = FileUtils.getBitmapScaledToDisplay(f, screenHeight, screenWidth); if (bmp == null) { mErrorTextView.setVisibility(View.VISIBLE); } mImageView.setImageBitmap(bmp); } else { mImageView.setImageBitmap(null); } mImageView.setPadding(10, 10, 10, 10); mImageView.setAdjustViewBounds(true); mImageView.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Collect.getInstance() .getActivityLogger() .logInstanceAction(this, "viewImage", "click", mPrompt.getIndex()); launchSignatureActivity(); } }); addView(mImageView); } }
/** * Method to add the image by setting and creating the views dynamically with delete and zoom * option. */ @SuppressWarnings("deprecation") private void getImageLayout(Bitmap p_bitmap) { ViewsVo m_signVo; // Check for images count .Set the count for limiting the number of images to add on screen. if (m_ImageCount < 1) { m_viewsAddedHeightEmotions = m_viewsAddedHeightEmotions + 90; m_ImageCount++; } /* * else { Toast.makeText(m_context, "No enough space for images.", * Toast.LENGTH_LONG).show(); } */ m_btnSDeleteImage = new Button(m_context); m_btnZoom = new Button(m_context); m_ivtmpImage = new ImageView(m_context); setViewsHeightDynamically(); // System.err.println("Height of Layout------" + m_absHeight); m_btnSDeleteImage.setLayoutParams(m_layoutparamsDelete); m_btnSDeleteImage.setBackgroundDrawable(getResources().getDrawable(R.drawable.ic_deletered)); m_btnSDeleteImage.setId(0); m_btnSDeleteImage.setOnClickListener(new ImageDeleteListener()); m_btnZoom.setLayoutParams(m_layoutParamsEdit); m_btnZoom.setBackgroundDrawable(getResources().getDrawable(R.drawable.right_arrow)); m_btnZoom.setId(0); m_absTextlayout = new AbsoluteLayout(m_context); m_absZoomlayout = new AbsoluteLayout(m_context); m_ivtmpImage.setImageBitmap(Bitmap.createScaledBitmap(p_bitmap, 400, 180, true)); m_absTextlayout.setLayoutParams( new AbsoluteLayout.LayoutParams( AbsoluteLayout.LayoutParams.WRAP_CONTENT, AbsoluteLayout.LayoutParams.WRAP_CONTENT, 0, 0)); m_absZoomlayout.setLayoutParams( new AbsoluteLayout.LayoutParams( AbsoluteLayout.LayoutParams.WRAP_CONTENT, AbsoluteLayout.LayoutParams.WRAP_CONTENT, 0, 0)); if (m_absHeight >= 900) m_ivtmpImage.setLayoutParams(new FrameLayout.LayoutParams(400, 200)); else m_ivtmpImage.setLayoutParams(new FrameLayout.LayoutParams(80, 80)); m_ivtmpImage.setBackgroundColor(Color.TRANSPARENT); m_absTextlayout.addView(m_btnSDeleteImage); if (m_absHeight >= 900) m_absZoomlayout.setPadding(0, 0, 0, 0); else m_absZoomlayout.setPadding(0, 0, 0, 0); m_absZoomlayout.setBackgroundResource(R.drawable.dashedbordersmall); m_absZoomlayout.addView(m_ivtmpImage); m_absTextlayout.addView(m_absZoomlayout); m_absTextlayout.addView(m_btnZoom); m_absTextlayout.setDrawingCacheEnabled(true); m_absTextlayout.setClickable(true); m_absTextlayout.setId(0); m_ivtmpImage.setId(0); m_vtoTree = m_absTextlayout.getViewTreeObserver(); m_vtoTree.addOnGlobalLayoutListener( new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { m_absTextlayout.getViewTreeObserver().removeGlobalOnLayoutListener(this); } }); /** * Add all the views into arraylist which are added into the screen for further to perform * deletion of each views. */ m_signVo = new ViewsVo(); m_arrSignObjects.add(0, m_signVo); m_absolutelayout.addView(m_absTextlayout); // Image touch listener to move image onTouch event on screen. m_touchImagListener = new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction() & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_DOWN: m_oldX = event.getX(); m_oldY = event.getY(); break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_POINTER_UP: break; case MotionEvent.ACTION_MOVE: m_dX = event.getX() - m_oldX; m_dY = event.getY() - m_oldY; m_posX = m_prevX + m_dX; m_posY = m_prevY + m_dY; if (m_posX > 0 && m_posY > 0 && (m_posX + v.getWidth()) < m_absolutelayout.getWidth() && (m_posY + v.getHeight()) < m_absolutelayout.getHeight()) { v.setLayoutParams( new AbsoluteLayout.LayoutParams( v.getMeasuredWidth(), v.getMeasuredHeight(), (int) m_posX, (int) m_posY)); m_prevX = m_posX; m_prevY = m_posY; } break; } return false; } }; // Listener for the arrow ontouch of arrow ZoomIn and ZoomOut the image. m_strecthArrowListener = new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { View view; // RemoveBorders(); view = v; v.setClickable(true); v.setDrawingCacheEnabled(true); AbsoluteLayout m_absLayout = null; switch (event.getAction() & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_DOWN: m_oldX = event.getX(); m_oldY = event.getY(); break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_POINTER_UP: break; case MotionEvent.ACTION_MOVE: m_newX = event.getX(); m_newY = event.getY(); float newDist = m_newX - m_oldX; if (m_newX > m_oldX && m_newY > m_oldY) { if (newDist > 0.0f) { m_scale = 1; m_absLayout = (AbsoluteLayout) v.getParent(); int m_hightOfImage = (int) (m_scale + (((ImageView) ((AbsoluteLayout) m_absLayout.getChildAt(1)).getChildAt(0)) .getHeight())); int m_widthOfImage = (int) (m_scale + (((ImageView) ((AbsoluteLayout) m_absLayout.getChildAt(1)).getChildAt(0)) .getWidth())); m_widthDelete = (int) (m_scale + ((((AbsoluteLayout) m_absLayout.getChildAt(1))).getWidth())); m_heightDelete = (int) (m_scale + ((((AbsoluteLayout) m_absLayout.getChildAt(1)).getHeight()))); if (m_absLayout.getBottom() <= (m_ivImage.getBottom()) && m_absLayout.getRight() <= (m_DisplayWidth)) { m_layoutparams = new AbsoluteLayout.LayoutParams(m_widthOfImage, m_hightOfImage, 0, 0); ((ImageView) ((AbsoluteLayout) m_absLayout.getChildAt(1)).getChildAt(0)) .setLayoutParams(m_layoutparams); m_layoutparams = new AbsoluteLayout.LayoutParams( AbsoluteLayout.LayoutParams.WRAP_CONTENT, AbsoluteLayout.LayoutParams.WRAP_CONTENT, m_absLayout.getLeft(), m_absLayout.getTop()); m_absLayout.setLayoutParams(m_layoutparams); ((Button) m_absLayout.getChildAt(0)) .setLayoutParams( new AbsoluteLayout.LayoutParams( m_deleteEditHeightwidth, m_deleteEditHeightwidth, m_widthDelete, 0)); ((Button) m_absLayout.getChildAt(2)) .setLayoutParams( new AbsoluteLayout.LayoutParams( m_deleteEditHeightwidth, m_deleteEditHeightwidth, m_widthDelete, m_heightDelete)); m_hightOfImage = (int) (m_scale + (((AbsoluteLayout) m_absLayout.getChildAt(1)).getHeight())); m_widthOfImage = (int) (m_scale + (((AbsoluteLayout) m_absLayout.getChildAt(1)).getWidth())); m_layoutparams = new AbsoluteLayout.LayoutParams( m_widthOfImage, m_hightOfImage, ((AbsoluteLayout) m_absLayout.getChildAt(1)).getLeft(), ((AbsoluteLayout) m_absLayout.getChildAt(1)).getTop()); ((AbsoluteLayout) m_absLayout.getChildAt(1)).setLayoutParams(m_layoutparams); } } } if (m_newX < m_oldX && m_newY < m_oldY) { m_absLayout = (AbsoluteLayout) view.getParent(); int m_hightOfImage = (int) (((ImageView) ((AbsoluteLayout) m_absLayout.getChildAt(1)).getChildAt(0)) .getHeight() - m_scale); int m_widthOfImage = (int) (((ImageView) ((AbsoluteLayout) m_absLayout.getChildAt(1)).getChildAt(0)) .getWidth() - m_scale); m_widthDelete = (int) (((AbsoluteLayout) m_absLayout.getChildAt(1)).getWidth() - m_scale); m_layoutparams = new AbsoluteLayout.LayoutParams(m_widthOfImage, m_hightOfImage, 0, 0); ((ImageView) ((AbsoluteLayout) m_absLayout.getChildAt(1)).getChildAt(0)) .setLayoutParams(m_layoutparams); m_layoutparams = new AbsoluteLayout.LayoutParams( AbsoluteLayout.LayoutParams.WRAP_CONTENT, AbsoluteLayout.LayoutParams.WRAP_CONTENT, m_absLayout.getLeft(), m_absLayout.getTop()); m_absLayout.setLayoutParams(m_layoutparams); ((Button) m_absLayout.getChildAt(0)) .setLayoutParams( new AbsoluteLayout.LayoutParams( m_deleteEditHeightwidth, m_deleteEditHeightwidth, m_widthDelete, 0)); ((Button) m_absLayout.getChildAt(2)) .setLayoutParams( new AbsoluteLayout.LayoutParams( m_deleteEditHeightwidth, m_deleteEditHeightwidth, m_widthDelete, m_widthDelete)); m_hightOfImage = (int) ((((AbsoluteLayout) m_absLayout.getChildAt(1)).getHeight()) - m_scale); m_widthOfImage = (int) ((((AbsoluteLayout) m_absLayout.getChildAt(1)).getWidth()) - m_scale); m_layoutparams = new AbsoluteLayout.LayoutParams( m_widthOfImage, m_hightOfImage, ((AbsoluteLayout) m_absLayout.getChildAt(1)).getLeft(), ((AbsoluteLayout) m_absLayout.getChildAt(1)).getTop()); ((AbsoluteLayout) m_absLayout.getChildAt(1)).setLayoutParams(m_layoutparams); } break; } return false; } }; m_absTextlayout.setOnTouchListener(m_touchImagListener); m_btnZoom.setOnTouchListener(m_strecthArrowListener); }
public AnnotateWidget(Context context, FormEntryPrompt prompt) { super(context, prompt); mInstanceFolder = Collect.getInstance().getFormController().getInstancePath().getParent(); setOrientation(LinearLayout.VERTICAL); TableLayout.LayoutParams params = new TableLayout.LayoutParams(); params.setMargins(7, 5, 7, 5); mErrorTextView = new TextView(context); mErrorTextView.setId(QuestionWidget.newUniqueId()); mErrorTextView.setText("Selected file is not a valid image"); // setup capture button mCaptureButton = new Button(getContext()); mCaptureButton.setId(QuestionWidget.newUniqueId()); mCaptureButton.setText(getContext().getString(R.string.capture_image)); mCaptureButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mAnswerFontsize); mCaptureButton.setPadding(20, 20, 20, 20); mCaptureButton.setEnabled(!prompt.isReadOnly()); mCaptureButton.setLayoutParams(params); // launch capture intent on click mCaptureButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Collect.getInstance() .getActivityLogger() .logInstanceAction(this, "captureButton", "click", mPrompt.getIndex()); mErrorTextView.setVisibility(View.GONE); Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); // We give the camera an absolute filename/path where to put the // picture because of bug: // http://code.google.com/p/android/issues/detail?id=1480 // The bug appears to be fixed in Android 2.0+, but as of feb 2, // 2010, G1 phones only run 1.6. Without specifying the path the // images returned by the camera in 1.6 (and earlier) are ~1/4 // the size. boo. // if this gets modified, the onActivityResult in // FormEntyActivity will also need to be updated. i.putExtra( android.provider.MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(Collect.TMPFILE_PATH))); try { Collect.getInstance().getFormController().setIndexWaitingForData(mPrompt.getIndex()); ((Activity) getContext()).startActivityForResult(i, FormEntryActivity.IMAGE_CAPTURE); } catch (ActivityNotFoundException e) { Toast.makeText( getContext(), getContext().getString(R.string.activity_not_found, "image capture"), Toast.LENGTH_SHORT) .show(); Collect.getInstance().getFormController().setIndexWaitingForData(null); } } }); // setup chooser button mChooseButton = new Button(getContext()); mChooseButton.setId(QuestionWidget.newUniqueId()); mChooseButton.setText(getContext().getString(R.string.choose_image)); mChooseButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mAnswerFontsize); mChooseButton.setPadding(20, 20, 20, 20); mChooseButton.setEnabled(!prompt.isReadOnly()); mChooseButton.setLayoutParams(params); // launch capture intent on click mChooseButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Collect.getInstance() .getActivityLogger() .logInstanceAction(this, "chooseButton", "click", mPrompt.getIndex()); mErrorTextView.setVisibility(View.GONE); Intent i = new Intent(Intent.ACTION_GET_CONTENT); i.setType("image/*"); try { Collect.getInstance().getFormController().setIndexWaitingForData(mPrompt.getIndex()); ((Activity) getContext()).startActivityForResult(i, FormEntryActivity.IMAGE_CHOOSER); } catch (ActivityNotFoundException e) { Toast.makeText( getContext(), getContext().getString(R.string.activity_not_found, "choose image"), Toast.LENGTH_SHORT) .show(); Collect.getInstance().getFormController().setIndexWaitingForData(null); } } }); // setup Blank Image Button mAnnotateButton = new Button(getContext()); mAnnotateButton.setId(QuestionWidget.newUniqueId()); mAnnotateButton.setText(getContext().getString(R.string.markup_image)); mAnnotateButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mAnswerFontsize); mAnnotateButton.setPadding(20, 20, 20, 20); mAnnotateButton.setEnabled(false); mAnnotateButton.setLayoutParams(params); // launch capture intent on click mAnnotateButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Collect.getInstance() .getActivityLogger() .logInstanceAction(this, "annotateButton", "click", mPrompt.getIndex()); launchAnnotateActivity(); } }); // finish complex layout addView(mCaptureButton); addView(mChooseButton); addView(mAnnotateButton); addView(mErrorTextView); // and hide the capture, choose and annotate button if read-only if (prompt.isReadOnly()) { mCaptureButton.setVisibility(View.GONE); mChooseButton.setVisibility(View.GONE); mAnnotateButton.setVisibility(View.GONE); } mErrorTextView.setVisibility(View.GONE); // retrieve answer from data model and update ui mBinaryName = prompt.getAnswerText(); // Only add the imageView if the user has taken a picture if (mBinaryName != null) { if (!prompt.isReadOnly()) { mAnnotateButton.setEnabled(true); } mImageView = new ImageView(getContext()); mImageView.setId(QuestionWidget.newUniqueId()); Display display = ((WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE)) .getDefaultDisplay(); int screenWidth = display.getWidth(); int screenHeight = display.getHeight(); File f = new File(mInstanceFolder + File.separator + mBinaryName); if (f.exists()) { Bitmap bmp = FileUtils.getBitmapScaledToDisplay(f, screenHeight, screenWidth); if (bmp == null) { mErrorTextView.setVisibility(View.VISIBLE); } mImageView.setImageBitmap(bmp); } else { mImageView.setImageBitmap(null); } mImageView.setPadding(10, 10, 10, 10); mImageView.setAdjustViewBounds(true); mImageView.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Collect.getInstance() .getActivityLogger() .logInstanceAction(this, "viewImage", "click", mPrompt.getIndex()); launchAnnotateActivity(); } }); addView(mImageView); } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.d(LT, "App created."); Events.intEnableDebug(1); // disable the titlebar requestWindowFeature(Window.FEATURE_NO_TITLE); // create a basic user interface LinearLayout panel = new LinearLayout(this); panel.setOrientation(LinearLayout.VERTICAL); setContentView(panel); // -- Button b = new Button(this); b.setText("Scan Input Devs"); b.setId(idButScan); b.setOnClickListener(this); panel.addView(b); // -- m_lvDevices = new ListView(this); m_lvDevices.setLayoutParams( new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); m_lvDevices.setId(idLVDevices); m_lvDevices.setDividerHeight(0); m_lvDevices.setFadingEdgeLength(0); m_lvDevices.setCacheColorHint(0); m_lvDevices.setAdapter(null); panel.addView(m_lvDevices); // -- LinearLayout panelH = new LinearLayout(this); panelH.setOrientation(LinearLayout.HORIZONTAL); panel.addView(panelH); // -- m_selDevSpinner = new Spinner(this); m_selDevSpinner.setLayoutParams( new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); m_selDevSpinner.setId(idSelSpin); m_selDevSpinner.setOnItemSelectedListener((OnItemSelectedListener) this); panelH.addView(m_selDevSpinner); // -- simulate key event b = new Button(this); b.setText(">Key"); b.setId(idButInjectKey); b.setOnClickListener(this); panelH.addView(b); // -- simulate touch event b = new Button(this); b.setText(">Tch"); b.setId(idButInjectTouch); b.setOnClickListener(this); panelH.addView(b); // -- m_tvMonitor = new TextView(this); m_tvMonitor.setText("Event Monitor stopped."); panel.addView(m_tvMonitor); // -- panelH = new LinearLayout(this); panelH.setOrientation(LinearLayout.HORIZONTAL); panel.addView(panelH); // -- b = new Button(this); b.setText("Monitor Start"); b.setId(idButMonitorStart); b.setOnClickListener(this); panelH.addView(b); // -- b = new Button(this); b.setText("Monitor Stop"); b.setId(idButMonitorStop); b.setOnClickListener(this); panelH.addView(b); // -- simulate test event b = new Button(this); b.setText(">Test"); b.setId(idButTest); b.setOnClickListener(this); panelH.addView(b); }
/** 初始化界面使用控件 */ public void initInterface() { scrollView = new ScrollView(this); TableLayout table = new TableLayout(this); TableLayout.LayoutParams paramsTable = new TableLayout.LayoutParams( TableLayout.LayoutParams.FILL_PARENT, TableLayout.LayoutParams.FILL_PARENT); table.setLayoutParams(paramsTable); TableRow row1 = new TableRow(this); homeTimeLine = new Button(this); homeTimeLine.setText("主人页时间线"); homeTimeLine.setId(1001); homeTimeLine.setOnClickListener(this); row1.addView(homeTimeLine); userTimeLine = new Button(this); userTimeLine.setText("客人页时间线"); userTimeLine.setId(1002); userTimeLine.setOnClickListener(this); row1.addView(userTimeLine); table.addView(row1); TableRow row2 = new TableRow(this); addWeibo = new Button(this); addWeibo.setText("普通发表接口"); addWeibo.setId(1003); addWeibo.setOnClickListener(this); row2.addView(addWeibo); addPic = new Button(this); addPic.setText("发表带图微博"); addPic.setId(1004); addPic.setOnClickListener(this); row2.addView(addPic); table.addView(row2); TableRow row3 = new TableRow(this); addPicUrl = new Button(this); addPicUrl.setText("发表带网络图片微博"); addPicUrl.setId(1005); addPicUrl.setOnClickListener(this); row3.addView(addPicUrl); htTimeLine = new Button(this); htTimeLine.setText("话题时间线"); htTimeLine.setId(1006); htTimeLine.setOnClickListener(this); row3.addView(htTimeLine); table.addView(row3); TableRow row4 = new TableRow(this); userInfo = new Button(this); userInfo.setText("获取用户信息"); userInfo.setId(1007); userInfo.setOnClickListener(this); row4.addView(userInfo); userOtherInfo = new Button(this); userOtherInfo.setText("获取他人信息"); userOtherInfo.setId(1008); userOtherInfo.setOnClickListener(this); row4.addView(userOtherInfo); table.addView(row4); TableRow row5 = new TableRow(this); userInfos = new Button(this); userInfos.setText("获取一批人信息"); userInfos.setId(1009); userInfos.setOnClickListener(this); row5.addView(userInfos); friendAdd = new Button(this); friendAdd.setText("收听某个用户"); friendAdd.setId(1010); friendAdd.setOnClickListener(this); row5.addView(friendAdd); table.addView(row5); TableRow row6 = new TableRow(this); friendIdolList = new Button(this); friendIdolList.setText("获取偶像列表"); friendIdolList.setId(1011); friendIdolList.setOnClickListener(this); row6.addView(friendIdolList); friendFunsList = new Button(this); friendFunsList.setText("获取粉丝列表"); friendFunsList.setId(1012); friendFunsList.setOnClickListener(this); row6.addView(friendFunsList); table.addView(row6); TableRow row7 = new TableRow(this); friendMutualList = new Button(this); friendMutualList.setText("获取互听列表"); friendMutualList.setId(1013); friendMutualList.setOnClickListener(this); row7.addView(friendMutualList); friendCheck = new Button(this); friendCheck.setText("验证好友关系"); friendCheck.setId(1014); friendCheck.setOnClickListener(this); row7.addView(friendCheck); table.addView(row7); TableRow row8 = new TableRow(this); tReList = new Button(this); tReList.setText("转播获取转播列表"); tReList.setId(1015); tReList.setOnClickListener(this); row8.addView(tReList); friendGetIntimateFriend = new Button(this); friendGetIntimateFriend.setText("获取最近联系人"); friendGetIntimateFriend.setId(1016); friendGetIntimateFriend.setOnClickListener(this); row8.addView(friendGetIntimateFriend); table.addView(row8); TableRow row9 = new TableRow(this); lbsGetAroundPeople = new Button(this); lbsGetAroundPeople.setText("获取附近的人"); lbsGetAroundPeople.setId(1017); lbsGetAroundPeople.setOnClickListener(this); row9.addView(lbsGetAroundPeople); lbsGetAroundNew = new Button(this); lbsGetAroundNew.setText("获取身边最新的微博"); lbsGetAroundNew.setId(1018); lbsGetAroundNew.setOnClickListener(this); row9.addView(lbsGetAroundNew); table.addView(row9); /*TableRow row10 = new TableRow(this); deviceStatus = new Button(this); deviceStatus.setText("终端状况"); deviceStatus.setId(1019); row10.addView(deviceStatus); errorReport = new Button(this); errorReport.setText("错误反馈"); errorReport.setId(1020); row10.addView(errorReport); table.addView(row10);*/ scrollView.addView(table); this.setContentView(scrollView); }