Is this even possible? I created this view flipper and I am calling the view flipper from the onClick inside of the xml layout. I have created a view flipper before but for some reason it's not working.
<?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:cacheColorHint="#android:color/transparent"
android:orientation="vertical" >
<ViewFlipper
android:id="#+id/viewFlipper1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#null"
android:cacheColorHint="#android:color/transparent" >
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/vf_sample1_main"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:cacheColorHint="#android:color/transparent"
android:orientation="vertical" >
<include layout="#layout/headers_main" />
<include layout="#layout/searchbar" />
<TextView
android:id="#+id/sdfsd"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:maxHeight="85dp"
android:paddingBottom="10dp"
android:paddingTop="10dp"
onClick="gotoSomething"
android:singleLine="false" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/aquablue"
android:textSize="15dp"
android:textStyle="bold" />
<include layout="#layout/listview_item_row_now_playing_info" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/aquablue"
android:textSize="15dp"
android:textStyle="bold" />
<include layout="#layout/container_listview" />
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/vf_sdfsdfadf"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#null"
android:cacheColorHint="#android:color/transparent"
android:orientation="vertical" >
<include layout="#layout/header_vf_asdfasdfadadafsd" />
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/vf_adsfasdfadsfasd"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#null"
android:cacheColorHint="#android:color/transparent"
android:orientation="vertical" >
</LinearLayout>
</ViewFlipper>
</LinearLayout>
code:
public class BeatSpotPrototypeActivity extends BaseListActivity {
private final String TAG = BeatSpotPrototypeActivity.class.getSimpleName();
private ApplicationStateManager mAppStateMananger = ApplicationStateManager.GetInstance();
private Context mCtx = null;
private boolean mIsInitalized = false;
private boolean mDataChanded= false;
private ViewFlipper mViewFlipper= null;
private DrawableManager mDrawManager = new DrawableManager();
private enum ViewFlipperModes {
MAIN (0),
NOW_PLAYING (1),
SONG_INFORMATION (2);
private final int index;
ViewFlipperModes(int index) {
this.index = index;
}
public int index() {
return index;
}
}
</code>
<code>
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_beatspot_activity);
if (!mIsInitalized)
init();
else
mDataChanded = true;
showLoading(false);
}
private void init() {
mCtx = this;
mIsInitalized = true;
mViewFlipper = (ViewFlipper)findViewById(R.id.viewFlipper);
fadeDrawables();
}
public void gotoBeatspotMain(View v) {
mViewFlipper.setDisplayedChild(ViewFlipperModes.MAIN.index());
}
public void gotoNowPlaying(View v) {
Log.d(TAG, mViewFlipper.getCurrentView().toString());
mViewFlipper.setDisplayedChild(ViewFlipperModes.NOW_PLAYING.index());
}
public void gotoSongDetails(View v) {
mViewFlipper.setDisplayedChild(ViewFlipperModes.SONG_INFORMATION.index());
Log.d(TAG, String.valueOf(ViewFlipperModes.SONG_INFORMATION.index()));
}
}
setDisplayedChild takes an index, not an id.
before on create
ViewFlipper mViewFlipper = (ViewFlipper)findViewbyId(location);
on your onCreate() or onStart
Ensure that whatever your layout on setcontentView(R.layout.something)
does contain the view flipper
Also try this for me. before this line mViewFlipper.setDisplayedChild(ViewFlipperModes.MAIN.index());
Type in:
int i = (ViewFlipperModes.MAIN.index()); place a debug point here
mViewFlipper.setDisplayedChild(i);
I also suggest using the debugger to try figure out if your flip views events are being called inside the debugger.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/book_as_whole_Layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#FFFFFF">
<ViewFlipper
android:layout_marginTop="20dip"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/ViewFlipper">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/page1"
android:text="#string/loading_string"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textColor="#000000"
android:typeface="serif"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/page2"
android:text="#string/loading_string"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textColor="#000000"
android:typeface="serif" />
</LinearLayout>
</ViewFlipper>
</LinearLayout>
Related
I have one relativeLayout and three view's inside RelativeLayout. There views are place on each other.
<RelativeLayout
android:id="#+id/includelayoutgroup"
android:layout_width="match_parent"
android:layout_height="match_parent">
<View xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/transparentColorView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:clickable="true"
android:visibility="visible" />
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/keyboard_main_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:visibility="visible">
<include
layout="#layout/transfer_keyboard_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/finalRequestView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:clickable="true"
android:visibility="visible">
<include
layout="#layout/fragment_transfer_new_version_container_child"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
</RelativeLayout>
Is it a possible to reverse position my view's? I mean,in my code last Layout is finalRequestView and in button click i would to my last view in first position,and other view's place on my view,
How i can solve this problem?
I try to reverse layout by following demo & it works as you want, please take a look
ReverseLayout.java
public class ReverseLayout extends AppCompatActivity {
LinearLayout llRoot;
Button btReverseLayout;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.reverse_layout);
llRoot = (LinearLayout) findViewById(R.id.llRoot);
btReverseLayout = (Button) findViewById(R.id.btReverseLayout);
btReverseLayout.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
ArrayList<View> alViews = new ArrayList<View>();
for (int i = llRoot.getChildCount() - 1; i >= 0; i--) {
View view = llRoot.getChildAt(i);
llRoot.removeViewAt(i);
alViews.add(view);
}
for (int j = 0; j < alViews.size(); j++) {
llRoot.addView(alViews.get(j));
}
}
});
}
}
reverse_layout.xml layout file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/activity_6"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.tosc185.testproject.Activity6">
<LinearLayout
android:id="#+id/llRoot"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FF0000"
android:gravity="center"
android:orientation="vertical"
android:padding="15dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1"
android:textSize="16dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#00FF00"
android:gravity="center"
android:orientation="vertical"
android:padding="15dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2"
android:textSize="16dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#0000FF"
android:gravity="center"
android:orientation="vertical"
android:padding="15dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="3"
android:textSize="16dp" />
</LinearLayout>
</LinearLayout>
<Button
android:id="#+id/btReverseLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="Reverse Layout" />
</RelativeLayout>
<LinearLayout
android:id="#+id/layout_question_detail"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:visibility="gone">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="55dp"
>
<Button
android:id="#+id/btn_question_backButton"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="#drawable/backicon_round"/>
<TextView
android:id="#+id/text_question_detail_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:textColor="#color/color_green"
android:text="Error"
android:textSize="19dp"
/>
</RelativeLayout>
<ImageView
android:id="#+id/image_question_detail_image"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3"
android:scaleType="centerCrop"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="vertical"
android:layout_weight="2">
<TextView
android:id="#+id/text_question_detail_userComments"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20dp"
android:layout_marginTop="10dp"
android:layout_weight="1"
android:layout_marginBottom="25dp"
/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="3">
<ListView
android:id="#+id/list_question_detail_expComments"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="#android:color/transparent"
android:dividerHeight="10dp"></ListView>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
Now, I set layout for title on the top. Then, a Imageview, a textview and a listview follow below this layout, and only 1 textview is inside listview.
listview can vary in size.
The problem is, if the size of the listview is very big, I can only scroll the screen assigned to listview.
But, I want scroll the entire screen.
To solve this problem, I added scrollview outside of the first linearlayout.
However, It didn't work.(the imageview disappeared)
What can I do?
you can make your listview addheaderview,and put your imageview and textview into headerview
yourlayout.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/layout_question_detail"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="55dp">
<Button
android:id="#+id/btn_question_backButton"
android:layout_width="50dp"
android:layout_height="50dp" />
<TextView
android:id="#+id/text_question_detail_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="Error"
android:textColor="#000000"
android:textSize="19dp"
/>
</RelativeLayout>
<ListView
android:id="#+id/list_question_detail_expComments"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="#android:color/transparent"
android:dividerHeight="10dp"></ListView>
lv_header.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<ImageView
android:id="#+id/image_question_detail_image"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3"
android:scaleType="centerCrop" />
<TextView
android:id="#+id/text_question_detail_userComments"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="25dp"
android:layout_marginTop="10dp"
android:layout_weight="1"
android:textSize="20dp" />
Activity.class
public class MainActivity extends AppCompatActivity {
private ListView list_question_detail_expComments;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
list_question_detail_expComments = (ListView) findViewById(R.id.list_question_detail_expComments);
View lvHeaderView = View.inflate(this,R.layout.lv_header,null);
list_question_detail_expComments.addHeaderView(lvHeaderView);
list_question_detail_expComments.setAdapter(new LvAdapter());
}
private class LvAdapter extends BaseAdapter{
#Override
public int getCount() {
return 20;
}
#Override
public Object getItem(int i) {
return null;
}
#Override
public long getItemId(int i) {
return 0;
}
#Override
public View getView(int i, View view, ViewGroup viewGroup) {
TextView tv = new TextView(MainActivity.this);
tv.setText("test"+i);
return tv;
}
}
}
With the layout below the buttons are being shown on top of the page. How can I make them appear below, after the container, down on the page?
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="#+id/container"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center_vertical|center_horizontal">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:id="#+id/Main"
android:onClick="ClickHomePage"
android:text= "#string/Home"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:id="#+id/map"
android:onClick="ClickClients"
android:text= "#string/Clients"
>
</Button>
</LinearLayout>
</LinearLayout>
The MainActivity looks as follows and the HomePage.xml is also below
public class MainActivity extends ActionBarActivity
{
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
GetButtonClicked(5);
setContentView(R.layout.activity_main);
}
public void GetButtonClicked(int position)
{
// update the main content by replacing fragments
Fragment fragment = null;
switch (position){
case 0:
fragment= new FirstPageFragment();
break;
default:
fragment = new FirstPageFragment();
break;
}
FragmentManager fragmentManager = getSupportFragmentManager();
fragmentManager.beginTransaction()
.replace(R.id.container, fragment)
.commit();
}
public void ClickHomePage(View view){
GetButtonClicked(0);
}
public void ClickClients(View view){
GetButtonClicked();
}
}
<FrameLayout 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" tools:context="com.test.FirstPageFragment" android:background="#drawable/theme">
</FrameLayout>
This is the FirstPage
public class FirstPageFragment extends Fragment {
public FirstPageFragment() {
// Required empty public constructor
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_first_page, container, false);
}
}
Use ralative layout insted of linear.
Make a different layout for bottom buttons, and then at the last of your container layout use this:
<include android:id="#+id/bottomLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
layout="#layout/bottom_buttons"/>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:orientation="horizontal" >
<Button
android:id="#+id/Main"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:onClick="ClickHomePage"
android:text="#string/Home" />
<Button
android:id="#+id/map"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:onClick="ClickClients"
android:text="#string/Clients" >
</Button>
</LinearLayout>
Try this
Use RelativeLayout with android:layout_alignParentBottom="true" step by step guide is available here.
Your skeleton for layout should look like this
<RelativeLayout
<LinearLayout android:layout_alignParentBottom="true">
<Button
<Button
</LinearLayout>
</RelativeLayout>
Final Layout
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/Main"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:onClick="ClickHomePage"
android:text="Home" />
<Button
android:layout_marginLeft="30dp"
android:id="#+id/map"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:onClick="ClickClients"
android:text="Clients" >
</Button>
</LinearLayout>
The issue was that I did not include the container in another layout...
<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"
tools:context="com.test.MainPageActivityActivity">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:id="#+id/container">
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:layout_alignParentTop="#+id/container">
and insert buttons layout here....
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:id="#+id/Main"
android:onClick="ClickHomePage"
android:text= "#string/Home"
/>
I detect the WIFI connect , when WIFI connect is break.
It will show the framelayout on the top of all widgets.
public class MjpegPlayerFragment extends Fragment {
public static FrameLayout reconnect_layout;
private class GetTimeStamp extends AsyncTask<URL, Integer, String> {
protected void onPostExecute(String result) {
Activity activity = getActivity() ;
if (activity != null) {
reconnect_fragment();
}
super.onPostExecute(result) ;
}
}
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.preview_player, container, false) ;
reconnect_layout = (FrameLayout) getActivity().findViewById(R.id.reconnect_layout);
return view ;
}
public static void reconnect_fragment() {
reconnect_layout.setVisibility(View.VISIBLE);
}
And the code of xml is like the following:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:baselineAligned="false"
android:orientation="vertical" >
<FrameLayout
android:id="#+id/reconnect_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:visibility="gone"
android:background="#454749">
<RelativeLayout
android:id="#+id/layout_imgbtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_centerVertical="true"
android:layout_above="#+id/bottom_buttonlayout"
android:layout_below="#+id/top_buttonlayout"
android:orientation="horizontal" >
<ImageView
android:id="#+id/phone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/connect"
android:layout_centerVertical="true"
android:background="#drawable/phone"/>
<ImageView
android:id="#+id/connect"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="#drawable/break1"/>
<ImageView
android:id="#+id/break_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/connect"
android:layout_centerVertical="true"
android:background="#drawable/camera_break"
/>
</RelativeLayout>
<LinearLayout
android:id="#+id/Reconnect_button_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_below="#+id/layout_break_text"
android:layout_centerInParent="true"
android:orientation="horizontal" >
<ImageButton
android:id="#+id/Imgbtn_reconnect"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_weight="1"
android:background="#00000000"
android:src="#drawable/reconnect" />
</LinearLayout>
<FrameLayout
android:id="#+id/player_frame"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<FrameLayout
android:id="#+id/player_surface_frame"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center" >
<SurfaceView
android:id="#+id/player_surface"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center" />
</FrameLayout>
</FrameLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/top_buttonlayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#444444" >
<ImageView
android:id="#+id/imageBackground"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:background="#drawable/logo"
/>
<ImageButton
android:id="#+id/SettingButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:scaleType="fitXY"
android:background="#drawable/parmeter_setting" />
<ImageButton
android:id="#+id/FileSavebutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:scaleType="fitXY"
android:background="#drawable/save_in_camera" />
</LinearLayout>
</RelativeLayout>
When it call the reconnect_fragment(); it show the java.lang.NullPointerException at reconnect_layout.setVisibility(View.VISIBLE);
Does there has any wrong ?
How to solve this problem ?
As you said in your comment framelayout is in fragment layout
So Change to
reconnect_layout = (FrameLayout) view.findViewById(R.id.reconnect_layout);
If it is in activity xml you use getActivity().findViewById
replace
reconnect_layout = (FrameLayout) getActivity().findViewById(R.id.reconnect_layout);
with
reconnect_layout = (FrameLayout) view.findViewById(R.id.reconnect_layout);
I am having trouble using ListActivity. If i change class extend from ListActivity to Activity it works fine. But then the trouble is how will i implement the onListItemClick. It muight be some small mistake i might have done but i am not able to trace it.
public class Warehouse extends ListActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
System.out.println("Inside Warehouse");
setContentView(R.layout.warehous);
LinearLayout linear = (LinearLayout) findViewById(R.id.linearfullview);
drawable = setBitMap(background_image);
linear.setBackgroundDrawable(drawable);
String[] names = new String[] { "Inventory Ageing",
"Inventory Carring Cost", "Inventory Turns" };
LinearLayout linearList = (LinearLayout) findViewById(R.id.linearlist);
drawable = setBitMap(list_image);
linearList.setBackgroundDrawable(drawable);
this.setListAdapter(new ArrayAdapter<String>(this,R.layout.warehouse_list,names));
// ListView lv = getListView(); lv.setTextFilterEnabled(true);
}
public Drawable setBitMap(String imagename) {
Bitmap image = BitmapFactory.decodeStream(getClass()
.getResourceAsStream(("/com/image/" + imagename + ".png")));
drawable = new BitmapDrawable(image);
return drawable;
}
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
Object o = this.getListAdapter().getItem(position);
String keyword = o.toString();
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent" android:orientation="horizontal"
android:layout_width="fill_parent">
<LinearLayout android:layout_width="fill_parent"
android:id="#+id/linearfullview" android:layout_height="400sp"
android:layout_alignParentTop="true" />
<LinearLayout android:layout_width="wrap_content"
android:layout_height="180sp" android:layout_alignParentBottom="true"
android:layout_marginTop="20sp">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id = "#+id/linearlist" android:layout_height="wrap_content" android:layout_width="wrap_content"
android:paddingLeft="2dp" android:paddingRight="2dp" android:gravity="bottom"
android:layout_marginTop="30dp">
<ListView android:id="#android:id/list" android:layout_width="100dip" android:layout_height="wrap_content"></ListView>
</LinearLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:paddingLeft="2dp" android:paddingRight="2dp"
android:paddingTop="4dp" android:gravity="bottom"
android:layout_marginTop="30dp">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content" android:id="#+id/linearFirst"
android:layout_alignParentLeft="true" android:layout_width="wrap_content"
android:paddingLeft="2dp" android:paddingRight="2dp"
android:paddingTop="4dp" android:gravity="bottom"
android:layout_marginTop="30dp" android:visibility="invisible">
<com.widget.WheelView
android:id="#+id/firstWheel" android:layout_height="wrap_content"
android:layout_width="100dp" />
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content" android:id="#+id/linearSecond"
android:layout_width="wrap_content" android:paddingLeft="2dp"
android:paddingRight="2dp" android:layout_alignParentRight="true"
android:paddingTop="4dp" android:gravity="bottom"
android:layout_marginTop="30dp" android:visibility="invisible">
<com.widget.WheelView
android:id="#+id/secondWheel" android:layout_height="wrap_content"
android:layout_width="100dp" />
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content" android:id="#+id/linearThird"
android:layout_width="wrap_content" android:paddingLeft="2dp"
android:paddingRight="2dp" android:paddingTop="4dp" android:gravity="bottom"
android:layout_marginTop="30dp" android:layout_alignParentLeft="true"
android:visibility="invisible">
<com.widget.WheelView
android:id="#+id/thirdWheel" android:layout_height="wrap_content"
android:layout_width="200dp" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
if you are extending ListActivity then you must take a Listview in main.xml with #+android:id/list
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent" android:orientation="horizontal"
android:layout_width="fill_parent">
<ListView android:id="#android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent" />
...
Can you use
public class Warehouse extends Activity implements onListItemClick
instead ?
refer http://www.vogella.de/articles/AndroidListView/article.html link.
There is a minor mistake ur making
Best of Luck...