Android实现QQ分组效果

来源:互联网 发布:mac装win7 usb3.0驱动 编辑:程序博客网 时间:2024/04/30 02:05

布局文件:

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="fill_parent"    android:layout_height="fill_parent"    android:orientation="vertical" >    <TextView         android:id="@+id/textView1"        android:layout_width="fill_parent"        android:layout_height="wrap_content"        android:text="分组一"         android:clickable="true"/>    <LinearLayout        android:id="@+id/linearLayout1"        android:layout_width="fill_parent"        android:layout_height="wrap_content"        android:layout_weight="1"          android:orientation="vertical">                 <TextView               android:layout_width="fill_parent"        android:layout_height="wrap_content"        android:text="内容1" />         <Button               android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="按钮" />         <Button        android:id="@+id/button1"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="Button" />             </LinearLayout>                     <TextView         android:id="@+id/textView2"        android:layout_width="fill_parent"        android:layout_height="wrap_content"        android:text="分组二"         android:clickable="true"/>            <LinearLayout        android:id="@+id/linearLayout2"        android:layout_width="fill_parent"        android:layout_height="wrap_content"        android:layout_weight="1" >                   <TextView              android:layout_width="fill_parent"        android:layout_height="wrap_content"        android:text="内容2" />    </LinearLayout>     <TextView         android:id="@+id/textView3"        android:layout_width="fill_parent"        android:layout_height="wrap_content"        android:text="分组三"         android:clickable="true"/>     <LinearLayout        android:id="@+id/linearLayout3"        android:layout_width="fill_parent"        android:layout_height="fill_parent"        android:layout_weight="0" >                    <TextView               android:layout_width="fill_parent"        android:layout_height="wrap_content"        android:text="内容3" />    </LinearLayout></LinearLayout>


 

 

代码部分:

package xuyan.QQ.fengzu;import android.app.Activity;import android.os.Bundle;import android.view.View;import android.widget.LinearLayout;import android.widget.TextView;public class QQfenzuActivity extends Activity {    /** Called when the activity is first created. */TextView text1,text2,text3;LinearLayout linearlayout1,linearlayout2,linearlayout3;    @Override    public void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.main);                text1=(TextView)this.findViewById(R.id.textView1);        text2=(TextView)this.findViewById(R.id.textView2);        text3=(TextView)this.findViewById(R.id.textView3);                linearlayout1=(LinearLayout)this.findViewById(R.id.linearLayout1);        linearlayout2=(LinearLayout)this.findViewById(R.id.linearLayout2);        linearlayout3=(LinearLayout)this.findViewById(R.id.linearLayout3);                text1.setOnClickListener(new View.OnClickListener() {public void onClick(View v) {// TODO Auto-generated method stublinearlayout1.setVisibility(View.VISIBLE);linearlayout2.setVisibility(View.GONE);linearlayout3.setVisibility(View.GONE);}});                text2.setOnClickListener(new View.OnClickListener() {public void onClick(View v) {// TODO Auto-generated method stublinearlayout1.setVisibility(View.GONE);linearlayout2.setVisibility(View.VISIBLE);linearlayout3.setVisibility(View.GONE);}});                text3.setOnClickListener(new View.OnClickListener() {public void onClick(View v) {// TODO Auto-generated method stub     linearlayout3.setVisibility(View.GONE);     linearlayout2.setVisibility(View.GONE);     linearlayout3.setVisibility(View.VISIBLE);}});    }}


 

参考的这里的博客:http://blog.csdn.net/weidi1989/article/details/7991188

原创粉丝点击