Tablet and Android Studios don't match each other's output

414 Views Asked by At

This question is an offshoot of another question I asked here: How to print message in an Android App

However I feel the problems I face are beyond the scope of the original question. In the original question I was asking how to get my Android App to print what I want to a screen and I was using a Tablet I was testing. The problem is in the design view of Android studio's it prints the string value that I want it too, but when I test on the tablet itself it simply print's "Hello World."

I believe the problem is either A...some connection/compatibility issue between the studios or my tablet.

Or B where my Android studios is out of date/the tutorial I was using is out of date. Tutorial can be found here: http://www.raywenderlich.com/78574/android-tutorial-for-beginners-part-1#comments

So I'm wondering if someone here can point out a compatibility issue with my tablet. Previous question I linked to in the beginning shows my code and our discussions on that. My tablet is a SM-T350 model shown here: http://www.samsung.com/us/mobile/galaxy-tab/SM-T350NZAAXAR

I'm not sure what version of Android studios I have but when I start it, it says an update for the studios IS available. If there is a way to check what version I have by release number I'd appreciate that information.

EDIT: my main_content.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"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        tools:showIn="@layout/activity_main"
        tools:context=".MainActivity">

       <TextView
         android:id="@+id/main_textview"
         android:text="@string/textview"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_marginLeft="20dp"
         android:layout_marginTop="20dp"
                                       />

       </LinearLayout>

EDIT: My MainActivity.java

     package com.example.dpolaristar.omgandroid;

     import android.os.Bundle;
     import android.support.design.widget.FloatingActionButton;
     import android.support.design.widget.Snackbar;
     import android.support.v7.app.AppCompatActivity;
     import android.support.v7.widget.Toolbar;
     import android.view.Menu;
     import android.view.View;
     import android.widget.TextView;

     public class MainActivity extends AppCompatActivity {
          TextView mainTextView;
          @Override
          protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          // 1. Access the TextView defined in layout XML
          // and then set its text
          //mainTextView = (TextView) findViewById(R.id.main_textview);
          //mainTextView.setText("Set in Java!");
          Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
          setSupportActionBar(toolbar);

          FloatingActionButton fab = (FloatingActionButton)    findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    });
}

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

}

EDIT: My activity_main.xml file.

     <?xml version="1.0" encoding="utf-8"?>
     <android.support.design.widget.CoordinatorLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.co/tools" 

      android:layout_width="match_parent"
      android:layout_height="match_parent" 
      android:fitsSystemWindows="true"
      tools:context=".MainActivity">

     <android.support.design.widget.AppBarLayout   

      android:layout_height="wrap_content"
      android:layout_width="match_parent"   
      android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.v7.widget.Toolbar android:id="@+id/toolbar"
        android:layout_width="match_parent"   
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"    
        app:popupTheme="@style/AppTheme.PopupOverlay" />

    </android.support.design.widget.AppBarLayout>

    <include layout="@layout/content_main" />

    <android.support.design.widget.FloatingActionButton  
       android:id="@+id/fab"
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content"
       android:layout_gravity="bottom|end"          
       android:layout_margin="@dimen/fab_margin"
       android:src="@android:drawable/ic_dialog_email" />

    </android.support.design.widget.CoordinatorLayout>
1

There are 1 best solutions below

8
geNia On

You posted the code of 'main_content.xml', while in your activity you are using the 'activity_main'

Take a look at the line

setContentView(R.layout.activity_main);

Do you include the 'main_content.xml' into your 'activity_main.xml'?