android界面 设计模式

不论什么系统,用什么语言开发,大多都会涉及到界面开发,界面开发中也有一些模式,一般用mvc的比较多,用了一个下午把一个以前写的小程序改了改,做了下比较,界面开发中如果用mvc、模板方法、中介者模式各有什么利弊。

第一种:模板+mvc
这种模式其实很简单,但是提出了一种界面开发的基本思路。android本身就有mvc的思想在里面,所以直接在activity的类中写各种逻辑倒是也可以,只不过初学者容易写的乱七八糟,这时候可以用“模板”模式进行一下封装,重点是开发者要把界面的初始化顺序、界面逻辑考虑清楚,千万不要混在一起写,那样以后就没法维护了。

在久其的DNA早期版本中,界面模板跟逻辑是放在一起的,界面的布局代码和逻辑混在一起,造成后期界面代码维护起来非常困难,后来模板改进了一下,把界面布局(xml)和界面类分的更开,在界面类中要得到控件需要调用getControls().getxx来找到具体的控件,这种思想跟android界面模板和activity的关系是一致的,我们在开发android界面时,也是通过findViewById(xx)来得到一个控件,然后调用控件的api,所以开发界面中一定要把界面的布局和逻辑实现分开,方便编写与测试。

示例代码:

ActivityTemplate.java

------------------------------------------------------------

package cainiao.mathexec.templatemethod;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;

public class ActivityTemplate extends Activity implementsOnClickListener{

@Override
protected final void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
doInit(savedInstanceState);
}

public void doInit(Bundle savedInstanceState) {
viewWillLoad(savedInstanceState);
initWidgets();
regListener();
viewDidLoad();
}

protected void viewWillLoad(Bundle savedInstanceState) {

}

protected void regListener() {

}

protected void initWidgets() {

}

protected void viewDidLoad() {

}

protected void viewWillDestroy() {

}
@Override
protected final void onDestroy() {
viewWillDestroy();
super.onDestroy();
}

@Override
public void onClick(View v) {
}
}

MainActivity3.java

----------------------------------------------

package cainiao.mathexec.templatemethod;

import java.text.DecimalFormat;

import cainiao.mathexec.R;
import cainiao.mathexec.R.layout;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;
import android.widget.Toast;

public class MainActivity3 extends ActivityTemplateimplements
OnEditorActionListener {

private TextView tvResult1;
private TextView tvResult2;
private EditText etA;
private EditText etB;
private EditText etC;
private Button btnCalc;
private DecimalFormat df = new DecimalFormat("#.####");

@Override
protected void viewWillLoad(Bundle savedInstanceState) {
System.out.println("view will load");
setContentView(R.layout.activity_main);

}

protected void initWidgets() {
System.out.println("init widgets");
tvResult1 = (TextView) findViewById(R.id.tvResult1);
tvResult2 = (TextView) findViewById(R.id.tvResult2);
etA = (EditText) findViewById(R.id.etA);
etB = (EditText) findViewById(R.id.etB);
etC = (EditText) findViewById(R.id.etC);
btnCalc = (Button) findViewById(R.id.btnCalc);
}

@Override
protected void regListener() {
System.out.println("reg listener");
btnCalc.setOnClickListener(this);
etC.setOnEditorActionListener(this);
}

@Override
protected void viewDidLoad() {
System.out.println("view did load");
setTitle("一元二次方程计算器");

InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
// 接受软键盘输入的编辑文本或其它视图
//imm.showSoftInput(etA,InputMethodManager.SHOW_FORCED);
imm.toggleSoftInput(0,InputMethodManager.HIDE_NOT_ALWAYS);
}

protected void viewWillDestroy() {
System.out.println("view will destroy");
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.miAbout:
Uri uri = Uri.parse("http://weibo.com/caniao");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);

}
return true;
}

@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.btnCalc:
if (doValidate()) {
docalc();
}
break;

default:
break;
}
}

private boolean doValidate() {
String strA = etA.getText().toString();
if (TextUtils.isEmpty(strA)) {
Toast.makeText(this, "请输入a", Toast.LENGTH_SHORT).show();
etA.requestFocus();
return false;
}

String strB = etB.getText().toString();
if (TextUtils.isEmpty(strB)) {
Toast.makeText(this, "请输入b", Toast.LENGTH_SHORT).show();
etB.requestFocus();
return false;
}

String strC = etC.getText().toString();
if (TextUtils.isEmpty(strC)) {
Toast.makeText(this, "请输入c", Toast.LENGTH_SHORT).show();
etC.requestFocus();
return false;
}

return true;
}

private void docalc() {
tvResult1.setText("x1=");
tvResult2.setText("x2=");
double a = Double.parseDouble(etA.getText().toString());
double b = Double.parseDouble(etB.getText().toString());
double c = Double.parseDouble(etC.getText().toString());

double res1;
double res2;
if (a == 0) {
res1 = -c / b;
tvResult1.setText("x=" + df.format(res1));
tvResult2.setText("只有一个解");

} else {
// 开方b^2 - 4ac
double tmp = Math.sqrt(b * b - 4 * a * c);

res1 = (-b + tmp) / (2 * a);
res2 = (-b - tmp) / (2 * a);
tvResult1.setText("x1=" + df.format(res1));
tvResult2.setText("x2=" + df.format(res2));
}

}

@Override
public boolean onEditorAction(TextView v, int actionId,KeyEvent event) {
switch (actionId) {
case EditorInfo.IME_ACTION_GO:
btnCalc.performClick();
break;
}
return false;
}
}


activity_main.xml
-------------------------------------------------------

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:tools="http://schemas.android.com/tools"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:orientation="vertical"

    android:paddingBottom="@dimen/activity_vertical_margin"

    android:paddingLeft="@dimen/activity_horizontal_margin"

    android:paddingRight="@dimen/activity_horizontal_margin"

    android:paddingTop="@dimen/activity_vertical_margin" >


    <RelativeLayout

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:layout_marginBottom="@dimen/activity_vertical_margin" >


        <EditText

            android:id="@+id/etA"

            android:layout_width="match_parent"

            android:layout_height="wrap_content"

            android:layout_alignParentLeft="true"

            android:layout_centerVertical="true"

            android:layout_toLeftOf="@+id/tvA"

            android:hint="a"

            android:inputType="numberSigned"

            android:nextFocusForward="@+id/etB" >


            <requestFocus />

        </EditText>


        <TextView

            android:id="@+id/tvA"

            android:layout_width="50dp"

            android:layout_height="wrap_content"

            android:layout_alignParentRight="true"

            android:layout_centerVertical="true"

            android:gravity="right"

            android:text="x2+"

            android:textAppearance="?android:attr/textAppearanceLarge" />

    </RelativeLayout>


    <RelativeLayout

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:layout_marginBottom="@dimen/activity_vertical_margin"

        android:orientation="horizontal" >


        <EditText

            android:id="@+id/etB"

            android:layout_width="match_parent"

            android:layout_height="wrap_content"

            android:layout_alignParentLeft="true"

            android:layout_centerVertical="true"

            android:layout_toLeftOf="@+id/tvB"

            android:layout_weight="1"

            android:hint="b"

            android:inputType="numberSigned"

            android:nextFocusForward="@+id/etC" >

        </EditText>


        <TextView

            android:id="@+id/tvB"

            android:layout_width="50dp"

            android:layout_height="wrap_content"

            android:layout_alignParentRight="true"

            android:layout_centerVertical="true"

            android:gravity="right"

            android:text="x+"

            android:textAppearance="?android:attr/textAppearanceLarge" />

    </RelativeLayout>


    <RelativeLayout

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:layout_marginBottom="@dimen/activity_vertical_margin"

        android:orientation="horizontal" >


        <EditText

            android:id="@+id/etC"

            android:layout_width="match_parent"

            android:layout_height="wrap_content"

            android:layout_alignParentLeft="true"

            android:layout_centerVertical="true"

            android:layout_toLeftOf="@+id/tvC"

            android:layout_weight="1"

            android:hint="c"

            android:imeOptions="actionGo"

            android:inputType="numberSigned"

            android:nextFocusForward="@+id/btnCalc" >

        </EditText>


        <TextView

            android:id="@+id/tvC"

            android:layout_width="50dp"

            android:layout_height="wrap_content"

            android:layout_alignParentRight="true"

            android:layout_centerVertical="true"

            android:gravity="right"

            android:text="=0"

            android:textAppearance="?android:attr/textAppearanceLarge" />

    </RelativeLayout>


    <Button

        android:id="@+id/btnCalc"

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:layout_marginBottom="@dimen/activity_vertical_margin"

        android:text="计算" />


    <LinearLayout

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:layout_marginBottom="@dimen/activity_vertical_margin"

        android:orientation="vertical" >


        <TextView

            android:id="@+id/tvResult"

            android:layout_width="match_parent"

            android:layout_height="wrap_content"

            android:text="结果:"

            android:textAppearance="?android:attr/textAppearanceLarge" />


        <TextView

            android:id="@+id/tvResult1"

            android:layout_width="match_parent"

            android:layout_height="wrap_content"

            android:text="x1= "

            android:textAppearance="?android:attr/textAppearanceLarge" />


        <TextView

            android:id="@+id/tvResult2"

            android:layout_width="match_parent"

            android:layout_height="wrap_content"

            android:text="x2= "

            android:textAppearance="?android:attr/textAppearanceLarge" />

    </LinearLayout>


</LinearLayout>


第二种就是用mvc,把所有的界面逻辑都放到另外一个类里面去,这种做法其实有点多此一举,因为android本身就把布局和逻辑分开了(布局文件用的是xml,逻辑用activity),但是如果布局是手写的,或者由其他的类生成的,逻辑不怎么变的话,还是可以考虑下这种方法。
示例代码如下:(界面xml文件跟上面的一样)

MainActivity2Controller.java

-------------------------------------------------------------------

package cainiao.mathexec.mvc;

import java.text.DecimalFormat;

import android.content.Context;
import android.content.ContextWrapper;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity2Controller {
private TextView tvResult1;
private TextView tvResult2;
private EditText etA;
private EditText etB;
private EditText etC;
private Button btnCalc;
private DecimalFormat df = new DecimalFormat("#.####");
private Context context;
public void setContext(Context context) {
this.context = context;
}

public void setTvResult1(View tvResult1) {
this.tvResult1 = (TextView) tvResult1;
}

public void setTvResult2(View tvResult2) {
this.tvResult2 = (TextView) tvResult2;
}

public void setEtA(View etA) {
this.etA = (EditText) etA;
}

public void setEtB(View etB) {
this.etB = (EditText) etB;
}

public void setEtC(View etC) {
this.etC = (EditText) etC;
}

public void setBtnCalc(View btnCalc) {
this.btnCalc = (Button) btnCalc;
}

public void doCalc() {
tvResult1.setText("x1=");
tvResult2.setText("x2=");
double a = Double.parseDouble(etA.getText().toString());
double b = Double.parseDouble(etB.getText().toString());
double c = Double.parseDouble(etC.getText().toString());

double res1;
double res2;
if (a == 0) {
res1 = -c / b;
tvResult1.setText("x=" + df.format(res1));
tvResult2.setText("只有一个解");

} else {
// 开方b^2 - 4ac
double tmp = Math.sqrt(b * b - 4 * a * c);

res1 = (-b + tmp) / (2 * a);
res2 = (-b - tmp) / (2 * a);
tvResult1.setText("x1=" + df.format(res1));
tvResult2.setText("x2=" + df.format(res2));
}
}

public boolean doValidate() {
String strA = etA.getText().toString();
if (TextUtils.isEmpty(strA)) {
Toast.makeText(context, "请输入a",Toast.LENGTH_SHORT).show();
etA.requestFocus();
return false;
}

String strB = etB.getText().toString();
if (TextUtils.isEmpty(strB)) {
Toast.makeText(context, "请输入b",Toast.LENGTH_SHORT).show();
etB.requestFocus();
return false;
}

String strC = etC.getText().toString();
if (TextUtils.isEmpty(strC)) {
Toast.makeText(context, "请输入c",Toast.LENGTH_SHORT).show();
etC.requestFocus();
return false;
}

return true;
}

public void init() {
btnCalc.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (doValidate()) {
doCalc();
}
}
});
}
public void destroy(){
btnCalc = null;
tvResult1 = null;
tvResult2 = null;
etA = null;
etB = null;
etC = null;
}

}

MainActivity2.java

------------------------------------------------------

package cainiao.mathexec.mvc;

import cainiao.mathexec.R;
import cainiao.mathexec.R.id;
import cainiao.mathexec.R.layout;
import android.app.Activity;
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity2 extends Activity {
private MainActivity2Controller mainActivity2Controller;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

mainActivity2Controller = new MainActivity2Controller();
mainActivity2Controller.setContext(this);
mainActivity2Controller.setEtA(findViewById(R.id.etA));
mainActivity2Controller.setEtB(findViewById(R.id.etB));
mainActivity2Controller.setEtC(findViewById(R.id.etC));
mainActivity2Controller.setTvResult1(findViewById(R.id.tvResult1));
mainActivity2Controller.setTvResult2(findViewById(R.id.tvResult2));
mainActivity2Controller.setBtnCalc(findViewById(R.id.btnCalc));
mainActivity2Controller.init();
}

@Override
protected void onDestroy() {
mainActivity2Controller.destroy();
super.onDestroy();
}
}


最后一种是“中介者(Mediator)”模式,说实话写起来非常难受,在这种场景用中介者好像不是很合适,而且中介者模式需要双向关联,让我极其不爽,而且思路也比较绕,也许是界面开发中这种“多对多”场景虽然有,但是不是主要的,所以用起来反而会增加复杂度。再一个,用它的话,界面中可能会用到自定义的控件,这样又多了一些复杂度也容易出错,还要加强转才能转成自定义类,所以界面开发还是少用这种模式。
示例代码:

BtnCalc.java

-------------------------------------

package cainiao.mathexec.mediator;

import android.content.Context;
import android.widget.Button;
import android.util.AttributeSet;
import android.view.View;
import android.view.View.OnClickListener;

public class BtnCalc extends Button implements OnClickListener{

private Mediator mediator;

public BtnCalc(Context context) {
this(context, null);
}

public BtnCalc(Context context, AttributeSet attrs) {
super(context, attrs);
setOnClickListener(this);
}

public void setMediator(Mediator m) {
this.mediator = m;
}

@Override
public void onClick(View v) {
if (null != mediator && mediator.doValidate()) {
mediator.doCalc();
}
}

}


EditTextC.java
----------------------------------
package cainiao.mathexec.mediator;

import android.content.Context;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.inputmethod.EditorInfo;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;

public class EditTextC extends EditText implementsOnEditorActionListener {
private Mediator mediator;

public void setMediator(Mediator mediator) {
this.mediator = mediator;
}

public EditTextC(Context context) {
this(context, null);
}

public EditTextC(Context context, AttributeSet attrs) {
super(context, attrs);
setOnEditorActionListener(this);
}

@Override
public boolean onEditorAction(TextView v, int actionId,KeyEvent event) {
switch (actionId) {
case EditorInfo.IME_ACTION_GO:
if (null != mediator && mediator.doValidate()) {
mediator.doCalc();
}
break;
}
return false;
}
}

MainActivity4.java

------------------------------------

package cainiao.mathexec.mediator;

import cainiao.mathexec.R;
import android.app.Activity;
import android.os.Bundle;

public class MainActivity4 extends Activity{
Mediator m = new Mediator();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
m.setBtnCalc(findViewById(R.id.btnCalc));
m.setContext(this);
m.setEtA(findViewById(R.id.etA));
m.setEtB(findViewById(R.id.etB));
m.setEtC(findViewById(R.id.etC));
m.setTvResult1(findViewById(R.id.tvResult1));
m.setTvResult2(findViewById(R.id.tvResult2));
}
}


Mediator.java
------------------------------
package cainiao.mathexec.mediator;

import java.text.DecimalFormat;

import android.content.Context;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;
import android.widget.Toast;

public class Mediator {
private TextView tvResult1;
private TextView tvResult2;
private EditText etA;
private EditText etB;
private cainiao.mathexec.mediator.EditTextC etC;
private BtnCalc btnCalc;
private DecimalFormat df = new DecimalFormat("#.####");
private Context context;
public void setContext(Context context) {
this.context = context;
}

public void setTvResult1(View tvResult1) {
this.tvResult1 = (TextView) tvResult1;
}

public void setTvResult2(View tvResult2) {
this.tvResult2 = (TextView) tvResult2;
}

public void setEtA(View etA) {
this.etA = (EditText) etA;
}

public void setEtB(View etB) {
this.etB = (EditText) etB;
}

public void setEtC(View etC) {
this.etC = (cainiao.mathexec.mediator.EditTextC) etC;
this.etC.setMediator(this);
}

public void setBtnCalc(View btnCalc) {
this.btnCalc = (cainiao.mathexec.mediator.BtnCalc)btnCalc;
this.btnCalc.setMediator(this);
}

public void doCalc() {
tvResult1.setText("x1=");
tvResult2.setText("x2=");
double a = Double.parseDouble(etA.getText().toString());
double b = Double.parseDouble(etB.getText().toString());
double c = Double.parseDouble(etC.getText().toString());

double res1;
double res2;
if (a == 0) {
res1 = -c / b;
tvResult1.setText("x=" + df.format(res1));
tvResult2.setText("只有一个解");

} else {
// 开方b^2 - 4ac
double tmp = Math.sqrt(b * b - 4 * a * c);

res1 = (-b + tmp) / (2 * a);
res2 = (-b - tmp) / (2 * a);
tvResult1.setText("x1=" + df.format(res1));
tvResult2.setText("x2=" + df.format(res2));
}
}

public boolean doValidate() {
String strA = etA.getText().toString();
if (TextUtils.isEmpty(strA)) {
Toast.makeText(context, "请输入a",Toast.LENGTH_SHORT).show();
etA.requestFocus();
return false;
}

String strB = etB.getText().toString();
if (TextUtils.isEmpty(strB)) {
Toast.makeText(context, "请输入b",Toast.LENGTH_SHORT).show();
etB.requestFocus();
return false;
}

String strC = etC.getText().toString();
if (TextUtils.isEmpty(strC)) {
Toast.makeText(context, "请输入c",Toast.LENGTH_SHORT).show();
etC.requestFocus();
return false;
}

return true;
}
}

activity_main2.xml
---------------------------------------------
 
 

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:tools="http://schemas.android.com/tools"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:orientation="vertical"

    android:paddingBottom="@dimen/activity_vertical_margin"

    android:paddingLeft="@dimen/activity_horizontal_margin"

    android:paddingRight="@dimen/activity_horizontal_margin"

    android:paddingTop="@dimen/activity_vertical_margin" >


    <RelativeLayout

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:layout_marginBottom="@dimen/activity_vertical_margin" >


        <EditText

            android:id="@+id/etA"

            android:layout_width="match_parent"

            android:layout_height="wrap_content"

            android:layout_alignParentLeft="true"

            android:layout_centerVertical="true"

            android:layout_toLeftOf="@+id/tvA"

            android:hint="a"

            android:inputType="numberSigned"

            android:nextFocusForward="@+id/etB" >


            <requestFocus />

        </EditText>


        <TextView

            android:id="@+id/tvA"

            android:layout_width="50dp"

            android:layout_height="wrap_content"

            android:layout_alignParentRight="true"

            android:layout_centerVertical="true"

            android:gravity="right"

            android:text="x2+"

            android:textAppearance="?android:attr/textAppearanceLarge" />

    </RelativeLayout>


    <RelativeLayout

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:layout_marginBottom="@dimen/activity_vertical_margin"

        android:orientation="horizontal" >


        <EditText

            android:id="@+id/etB"

            android:layout_width="match_parent"

            android:layout_height="wrap_content"

            android:layout_alignParentLeft="true"

            android:layout_centerVertical="true"

            android:layout_toLeftOf="@+id/tvB"

            android:layout_weight="1"

            android:hint="b"

            android:inputType="numberSigned"

            android:nextFocusForward="@+id/etC" >

        </EditText>


        <TextView

            android:id="@+id/tvB"

            android:layout_width="50dp"

            android:layout_height="wrap_content"

            android:layout_alignParentRight="true"

            android:layout_centerVertical="true"

            android:gravity="right"

            android:text="x+"

            android:textAppearance="?android:attr/textAppearanceLarge" />

    </RelativeLayout>


    <RelativeLayout

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:layout_marginBottom="@dimen/activity_vertical_margin"

        android:orientation="horizontal" >


        <cainiao.mathexec.mediator.EditTextC

            android:id="@+id/etC"

            android:layout_width="match_parent"

            android:layout_height="wrap_content"

            android:layout_alignParentLeft="true"

            android:layout_centerVertical="true"

            android:layout_toLeftOf="@+id/tvC"

            android:layout_weight="1"

            android:hint="c"

            android:imeOptions="actionGo"

            android:inputType="numberSigned"

            android:nextFocusForward="@+id/btnCalc" />


        <TextView

            android:id="@+id/tvC"

            android:layout_width="50dp"

            android:layout_height="wrap_content"

            android:layout_alignParentRight="true"

            android:layout_centerVertical="true"

            android:gravity="right"

            android:text="=0"

            android:textAppearance="?android:attr/textAppearanceLarge" />

    </RelativeLayout>


    <cainiao.mathexec.mediator.BtnCalc

        android:id="@+id/btnCalc"

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:layout_marginBottom="@dimen/activity_vertical_margin"

        android:text="计算" />


    <LinearLayout

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:layout_marginBottom="@dimen/activity_vertical_margin"

        android:orientation="vertical" >


        <TextView

            android:id="@+id/tvResult"

            android:layout_width="match_parent"

            android:layout_height="wrap_content"

            android:text="结果:"

            android:textAppearance="?android:attr/textAppearanceLarge" />


        <TextView

            android:id="@+id/tvResult1"

            android:layout_width="match_parent"

            android:layout_height="wrap_content"

            android:text="x1= "

            android:textAppearance="?android:attr/textAppearanceLarge" />


        <TextView

            android:id="@+id/tvResult2"

            android:layout_width="match_parent"

            android:layout_height="wrap_content"

            android:text="x2= "

            android:textAppearance="?android:attr/textAppearanceLarge" />

    </LinearLayout>


</LinearLayout>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值