2 Replies - 764 Views - Last Post: 27 October 2014 - 09:19 AM

#1 amture106   User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 159
  • Joined: 08-September 11

ViewSwitcher isn't resolving when being called

Posted 27 October 2014 - 08:18 AM

In my pursuit to modify the tutorial Android application Bluetooth Chat, I'm trying to add View Switcher to alternate between screens simultaneously in the app, but in my function onCreate ViewSwitcher isn't being resolving and I get a debugging error when trying to run the app. The spelling match and all required libraries are being called, so not sure how to fix it. My code for onCreate function is:
@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		if (D)
			Log.e(TAG, "+++ ON CREATE +++");

		// Set up the window layout
		setContentView(R.layout.main);
		
		// Set up the ViewSwitcher
		 viewSwitcher = (ViewSwitcher) findViewbyId(R.id.viewswitcher);

		// Define ViewSwitcher animations
		  slide_in_left = AnimationUtils.loadAnimation(this,
		    android.R.anim.slide_in_left);
		  slide_out_right = AnimationUtils.loadAnimation(this,
		    android.R.anim.slide_out_right);
		  
		  // set animations
		  viewSwitcher.setInAnimation(slide_in_left);
		  viewSwitcher.setOutAnimation(slide_out_right);


		// Get local Bluetooth adapter
		mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();

		// If the adapter is null, then Bluetooth is not supported
		if (mBluetoothAdapter == null) {
			Toast.makeText(this, "Bluetooth is not available",
					Toast.LENGTH_LONG).show();
			finish();
			return;
		}
	}


My code for main layout
<?xml version="1.0" encoding="utf-8"?>


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <!-- ViewSwitcher contains two LinearLayouts (screen1) and (screen2)  -->
     <ViewSwitcher
        android:id="@+id/viewswitcher"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
        
  <!-- First linearLayout (screen1) which contains 4 toggleButtons  -->
  
         <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:orientation="vertical" >

            <ToggleButton
                 android:id="@+id/toggleButton1"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:text="ToggleButton1" />
            
            <ToggleButton
                 android:id="@+id/toggleButton2"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:text="ToggleButton2" />
            
            <ToggleButton
                 android:id="@+id/toggleButton3"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:text="ToggleButton3" />
            
            <ToggleButton
                 android:id="@+id/toggleButton4"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:text="ToggleButton4" />
        </LinearLayout>

          <!-- Second linearLayout (screen2) which contains 6 seekBars  -->
         
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:orientation="vertical" >

          <SeekBar
                 android:id="@+id/seekBar1"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content" />
          
          <SeekBar
                 android:id="@+id/seekBar2"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content" />
          
          <SeekBar
                 android:id="@+id/seekBar3"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content" />
          
          <SeekBar
                 android:id="@+id/seekBar4"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content" />
          
           <SeekBar
                 android:id="@+id/seekBar5"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content" />
           
            <SeekBar
                 android:id="@+id/seekBar6"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content" />
        </LinearLayout>
    </ViewSwitcher>

    
    <ListView
        android:id="@+id/in"
        android:layout_width="match_parent"
        android:layout_height="0dip"
        android:layout_weight="0.74"
        android:stackFromBottom="true"
        android:transcriptMode="alwaysScroll" />
    
    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
        <EditText 
            android:id="@+id/edit_text_out"
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:layout_gravity="bottom"
        	android:inputType="text" />
        <Button 
            android:id="@+id/button_send"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/send" />
    </LinearLayout>
</LinearLayout>



Note:
Full source code can be found here

Is This A Good Question/Topic? 0
  • +

Replies To: ViewSwitcher isn't resolving when being called

#2 Dogstopper   User is offline

  • The Ninjaducky
  • member icon

Reputation: 2972
  • View blog
  • Posts: 11,223
  • Joined: 15-July 08

Re: ViewSwitcher isn't resolving when being called

Posted 27 October 2014 - 08:50 AM

I did not see any issues with that being a particular error. Have you tried to do a build/clean to rebuild the XML file?
Was This Post Helpful? 0
  • +
  • -

#3 amture106   User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 159
  • Joined: 08-September 11

Re: ViewSwitcher isn't resolving when being called

Posted 27 October 2014 - 09:19 AM

Yes I have, and I got those errors.

Attached image(s)

  • Attached Image
  • Attached Image

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1