0
我新的發展,但我有一個問題如何擺脫酒吧的Android中
這裏的東西,我相信你需要知道
主要活動
package com.mayubrand.basiccalculator;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class MainActivity extends ActionBarActivity implements View.OnClickListener {
private Button circumferenceB, areaB, diameterB;
private TextView resultTxt, radiusTxt, headingTxt;
private EditText radiusTF ;
public void onCreate(){
this.requestWindowFeature(Window.FEATURE_NO_TITLE);}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
init();
}
private void init(){
//Buttons
circumferenceB = (Button) findViewById(R.id.circumferenceB);
areaB = (Button) findViewById(R.id.areaB);
diameterB = (Button) findViewById(R.id.diameterB);
//Text Field (Edit Text)
radiusTF = (EditText) findViewById(R.id.radiusTF);
//Text (Text View)
resultTxt = (TextView) findViewById(R.id.resultTxt);
radiusTxt =(TextView) findViewById(R.id.radiusTxt);
headingTxt = (TextView) findViewById(R.id.radiusTxt);
//==============
//Listeners
circumferenceB.setOnClickListener(this);
areaB.setOnClickListener(this);
diameterB.setOnClickListener(this);
}
public void onClick(View view) {
String radiusEntered = radiusTF.getText().toString();
double pi = Math.PI;
int two = 2;
if(radiusEntered.equals("")) {
radiusTF.setText("");
}else{
switch (view.getId()){
case R.id.circumferenceB:
double circumference = Integer.parseInt(radiusEntered) * pi * two;
resultTxt.setText(String.valueOf(circumference));
break;
case R.id.areaB:
double area = pi * Integer.parseInt(radiusEntered) *Integer.parseInt(radiusEntered);
resultTxt.setText(String.valueOf(area));
break;
case R.id.diameterB:
double diameter = Integer.parseInt(radiusEntered) * 2;
resultTxt.setText(String.valueOf(diameter));
break;
}
}
}
代碼
}
主要活動XML
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="MayU Circle Calulator"
android:id="@+id/headingTxt"
android:textColor="#ffffff"
android:textStyle="bold"
android:textSize="35dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Radius"
android:id="@+id/radiusTxt"
android:layout_below="@+id/headingTxt"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="36dp"
android:textSize="23dp" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="number"
android:ems="10"
android:id="@+id/radiusTF"
android:layout_alignBottom="@+id/radiusTxt"
android:layout_alignRight="@+id/headingTxt"
android:layout_alignEnd="@+id/headingTxt" />
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/radiusTxt"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:weightSum="1">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Find Circumference"
android:id="@+id/circumferenceB"
android:layout_weight="0.08" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Find Area"
android:id="@+id/areaB"
android:layout_weight="0.08" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Find Diameter"
android:id="@+id/diameterB"
android:layout_gravity="center_horizontal"
android:layout_weight="0.08" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Result"
android:id="@+id/resultTxt"
android:layout_gravity="center_horizontal"
android:layout_weight="0.08"
android:textSize="40dp" />
</LinearLayout>
Android清單
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="Circle Calculator"
android:theme="@style/AppTheme"
>
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
當我在你安排所有的按鈕和文本,你必須在視覺上任何其他組件的佈局區域是它看起來不錯但是,只要我在模擬器或手機中啓動它,就有一個酒吧黑色/棕色酒吧就在那裏。我如何刪除它?在側
的另一件事,如何更改按鈕
你指的是什麼類型的酒吧?你能發佈一個截圖嗎? – ganeshvjy