我有ListView和button.when我点击按钮。它应该从上到下滑动当我再次按下按钮它再次滑动从底部到顶部。我在幻灯片后面有另一个布局我将能够看到另一个布局,但我无法专注于那个布局。我正在使用动画列表。我在anim文件夹中使用了两个xml。
I happily able to slide but I'm unable to get focus to behind view of listview
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
slide = (Button) findViewById(R.id.button_sliding);
button2 = (Button) findViewById(R.id.button3);
buuton1 = (Button) findViewById(R.id.button4);
ssss = (Button) findViewById(R.id.button5);
button2.setOnClickListener(this);
buuton1.setOnClickListener(this);
ssss.setOnClickListener(this);
list = (ListView) findViewById(R.id.listView1);
aa = new ArrayAdapter<String>(MainActivity.this,
android.R.layout.simple_list_item_1, ssp);
list.setAdapter(aa);
ll = (LinearLayout) findViewById(R.id.linearLayout1);
slide.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Animation slideDown = AnimationUtils.loadAnimation(
getApplicationContext(), R.anim.slide_down);
Animation slideUp = AnimationUtils.loadAnimation(
getApplicationContext(), R.anim.slide_up);
if (slidestatus == false) {
list.startAnimation(slideDown);
slidestatus = true;
} else {
list.startAnimation(slideUp);
slidestatus = false;
}
}
});
and my main xml
<RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.sanjeev.loginfrom.MainActivity" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="LOGIN FORM" />
<Button
android:id="@+id/button_sliding"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@+id/editText1"
android:layout_marginTop="17dp"
android:text="slide" />
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/button_sliding"
android:layout_alignRight="@+id/button_sliding"
android:layout_below="@+id/button_sliding"
android:layout_marginTop="29dp"
android:orientation="vertical" >
<Button
android:id="@+id/button6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:id="@+id/button5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
<ListView
android:id="@+id/listView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/button_sliding"
android:layout_centerHorizontal="true" >
</ListView>
</RelativeLayout>
How can i get focus to views behind the list view.
Thanks in advance
答案 0 :(得分:0)
将android:id="@+id/relative_layout"
添加到xml文件中的RelativeLayot。
现在从Activity获取RelativeLayout并关注,如下所示:
RelativeLayout relativeLayout = (RelativeLayout) findViewById(R.id.relative_layout);
relativeLayout.requestFocus();
你可以专注于你想要的任何地方。