首页

android 线型布局管理器(入门级)

java

2020-6-28

package com.example.radio;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.CheckBox;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;


public class MainActivity extends Activity {

	private RadioGroup radioContainer;
	private LinearLayout checkContainer;
	TextView tv1;
	TextView tv2;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        radioContainer=(RadioGroup)(findViewById(R.id.radioContainer));
		checkContainer=(LinearLayout)(findViewById(R.id.checkContainer));
		tv1=(TextView)findViewById(R.id.txtView);
		tv2=(TextView)findViewById(R.id.birthView);
    }
    public void buttonClick(View view)
	{
		Log.i("Button","Button Clicked");
	}
    public void btnDisplaySelected(View view)
	{
		String radioText="";
		for(int i=0;i<radioContainer.getChildCount();i  )
		{
			View c=radioContainer.getChildAt(i);
			if(c instanceof RadioButton)
			{
				RadioButton radio=(RadioButton)c;
				if(radio.isChecked())
				{
					radioText=radio.getText().toString();
				}
			}
		}
		tv1.setText(radioText);
		Log.i("Radio","Radio Selected is" radioText);
		String checkText="";
		for(int i=0;i<checkContainer.getChildCount();i  )
		{
			View c=checkContainer.getChildAt(i);
			if(c instanceof CheckBox)
			{
				CheckBox check=(CheckBox)c;
				if(check.isChecked())
				{
					checkText =check.getText().toString() ";";
				}
			}
		}
		tv2.setText(checkText);
		Log.i("Check","Check Selected is" checkText);
	}



    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}

资源下载此资源下载价格为3D币(VIP免费),请先
资源文件列表
╧▀╨═▓╝╛╓╣▄└φ╞≈/.classpath , 475
╧▀╨═▓╝╛╓╣▄└φ╞≈/.project , 843
╧▀╨═▓╝╛╓╣▄└φ╞≈/.settings/org.eclipse.jdt.core.prefs , 177
╧▀╨═▓╝╛╓╣▄└φ╞≈/AndroidManifest.xml , 860
╧▀╨═▓╝╛╓╣▄└φ╞≈/bin/AndroidManifest.xml , 860
╧▀╨═▓╝╛╓╣▄└φ╞≈/bin/classes/com/example/radio/BuildConfig.class , 343
╧▀╨═▓╝╛╓╣▄└φ╞≈/bin/classes/com/example/radio/MainActivity.class , 3094
╧▀╨═▓╝╛╓╣▄└φ╞≈/bin/classes/com/example/radio/R$attr.class , 337
╧▀╨═▓╝╛╓╣▄└φ╞≈/bin/classes/com/example/radio/R$dimen.class , 458
╧▀╨═▓╝╛╓╣▄└φ╞≈/bin/classes/com/example/radio/R$drawable.class , 404
╧▀╨═▓╝╛╓╣▄└φ╞≈/bin/classes/com/example/radio/R$id.class , 567
╧▀╨═▓╝╛╓╣▄└φ╞≈/bin/classes/com/example/radio/R$layout.class , 400
╧▀╨═▓╝╛╓╣▄└φ╞≈/bin/classes/com/example/radio/R$menu.class , 385
╧▀╨═▓╝╛╓╣▄└φ╞≈/bin/classes/com/example/radio/R$string.class , 469
╧▀╨═▓╝╛╓╣▄└φ╞≈/bin/classes/com/example/radio/R$style.class , 428
╧▀╨═▓╝╛╓╣▄└φ╞≈/bin/classes/com/example/radio/R.class , 663
╧▀╨═▓╝╛╓╣▄└φ╞≈/bin/classes.dex , 818088
╧▀╨═▓╝╛╓╣▄└φ╞≈/bin/dexedLibs/android-support-v4-46863b0851425362818b63440244abf7.jar , 273657
╧▀╨═▓╝╛╓╣▄└φ╞≈/bin/dexedLibs/android-support-v4-4700e801e5db1dc499bed76ce33b5c65.jar , 273657
╧▀╨═▓╝╛╓╣▄└φ╞≈/bin/jarlist.cache , 119
╧▀╨═▓╝╛╓╣▄└φ╞≈/bin/res/drawable-hdpi/ic_launcher.png , 5964
╧▀╨═▓╝╛╓╣▄└φ╞≈/bin/res/drawable-mdpi/ic_launcher.png , 3112
╧▀╨═▓╝╛╓╣▄└φ╞≈/bin/res/drawable-xhdpi/ic_launcher.png , 9355
╧▀╨═▓╝╛╓╣▄└φ╞≈/bin/res/drawable-xxhdpi/ic_launcher.png , 17889
╧▀╨═▓╝╛╓╣▄└φ╞≈/bin/resources.ap_ , 41595
╧▀╨═▓╝╛╓╣▄└φ╞≈/bin/zuoye_3.apk , 320057
╧▀╨═▓╝╛╓╣▄└φ╞≈/gen/com/example/radio/BuildConfig.java , 159
╧▀╨═▓╝╛╓╣▄└φ╞≈/gen/com/example/radio/R.java , 2885
╧▀╨═▓╝╛╓╣▄└φ╞≈/ic_launcher-web.png , 51394
╧▀╨═▓╝╛╓╣▄└φ╞≈/libs/android-support-v4.jar , 758727
╧▀╨═▓╝╛╓╣▄└φ╞≈/proguard-project.txt , 781
╧▀╨═▓╝╛╓╣▄└φ╞≈/project.properties , 563
╧▀╨═▓╝╛╓╣▄└φ╞≈/res/drawable-hdpi/ic_launcher.png , 7658
╧▀╨═▓╝╛╓╣▄└φ╞≈/res/drawable-mdpi/ic_launcher.png , 3777
╧▀╨═▓╝╛╓╣▄└φ╞≈/res/drawable-xhdpi/ic_launcher.png , 12516
╧▀╨═▓╝╛╓╣▄└φ╞≈/res/drawable-xxhdpi/ic_launcher.png , 24777
╧▀╨═▓╝╛╓╣▄└φ╞≈/res/layout/activity_main.xml , 3355
╧▀╨═▓╝╛╓╣▄└φ╞≈/res/menu/main.xml , 367
╧▀╨═▓╝╛╓╣▄└φ╞≈/res/values/dimens.xml , 220
╧▀╨═▓╝╛╓╣▄└φ╞≈/res/values/strings.xml , 222
╧▀╨═▓╝╛╓╣▄└φ╞≈/res/values/styles.xml , 697
╧▀╨═▓╝╛╓╣▄└φ╞≈/res/values-v11/styles.xml , 334
╧▀╨═▓╝╛╓╣▄└φ╞≈/res/values-v14/styles.xml , 391
╧▀╨═▓╝╛╓╣▄└φ╞≈/res/values-w820dp/dimens.xml , 381
╧▀╨═▓╝╛╓╣▄└φ╞≈/src/com/example/radio/MainActivity.java , 2434
没有账号? 忘记密码?

社交账号快速登录