So i have a main activity that commits the transaction of a fragment that inflates the activity with an image view just like a main cover, and with the button "Sign up" that takes you to the signUp activity. However, all of that does work like it shoulds, the transaction works and the inflater does too, but the problem comes when:
I am trying to call a fragment (signUpForm) from the activity (signUp). The root of the problem is that the fragment transaction to signUpForm is not working because the toast programmed on it is not showing, so it does not even get to the inflater.
signUp class:
package com.example.joshumberto.workcon;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.Toast;
public class signUp extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sign_up);
getSupportFragmentManager().beginTransaction()
.add(R.id.sign_up_container, new signUpForm(), "signUpForm").commit();
}
}
activity_sign_up.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:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="#+id/sign_up_container"
tools:context=".signUp" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="look, i should have inflated companions"
/>
</LinearLayout>
signUpForm class (only pasting the oncreate method, other things aren't needed):
package com.example.joshumberto.workcon;
import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.Toast;
public class signUpForm extends Fragment implements View.OnClickListener {
EditText correo;
EditText telefono;
Button continuar;
public signUpForm(){
}
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// setHasOptionsMenu(true);
}
public View OnCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
Toast.makeText(
getActivity(),
"i am supposued to be created!!",
Toast.LENGTH_LONG).show();
View v = inflater.inflate(R.layout.fragment_sign_up_form, container, false);
correo = (EditText) v.findViewById(R.id.txt_usuario_correo);
telefono = (EditText) v.findViewById(R.id.txt_usuario_telefono);
continuar = (Button) v.findViewById(R.id.btn_registro_continuar);
continuar.setOnClickListener(this);
return v;
}
fragment_sign_up_form.xml (just button,textview and edit texts to inflate activity)
<LinearLayout 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:orientation="vertical"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:background="#color/colorSignUpBackground"
tools:context=".signUp"
android:id="#+id/sign_up_form" >
<!--<include android:id="#+id/toolbar"
layout="#layout/toolbar" />-->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Registro"
android:fontFamily="sans-serif-smallcaps"
android:textSize="#dimen/titulo_txt"
android:id="#+id/textView"
android:layout_gravity="center_horizontal"
android:layout_marginTop="#dimen/margin_top_standar" />
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="20dp">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/txt_usuario_correo"
android:layout_marginTop="#dimen/margin_top_login_btn"
android:hint="Correo"
android:gravity="center"
android:layout_gravity="center_horizontal" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/txt_usuario_contrasena"
android:layout_marginTop="#dimen/margin_top_login_btn"
android:hint="Contrasena"
android:gravity="center"
android:layout_gravity="center_horizontal" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/txt_usuario_telefono"
android:layout_marginTop="#dimen/margin_top_login_btn"
android:hint="Telefono"
android:gravity="center"
android:layout_gravity="center_horizontal" />
</LinearLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Continuar"
android:id="#+id/btn_registro_continuar"
android:layout_gravity="center_horizontal" />
<!--<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/miLista"
></ListView>-->
Ideas? Thanks.
You should try replace() method instead of add(). like this.
getSupportFragmentManager().beginTransaction().replace(R.id.sign_up_container, new signUpForm(), "signUpForm").commit();
Related
I recently learned about Fragments in Android and was building a notepad application to practice them.
Idea: The idea behind the app is simple. I press the button to add a new note. A CardView Viewgroup turns visible. The fragment will be housed within this CardView.
Problem: When I press the button to add a new note, the fragment does not pop up.
MainActivity.java
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.cardview.widget.CardView;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import java.util.Objects;
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
private CardView fragmentCardView;
private Button newNoteButton;
private FragmentManager fragmentManager = getSupportFragmentManager();
private FragmentTransaction fragmentTransaction;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setActionBar();
newNoteButton = findViewById(R.id.new_note_button);
fragmentCardView = findViewById(R.id.fragment_cardView);
}
void setActionBar(){
Objects.requireNonNull(getSupportActionBar()).setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
getSupportActionBar().setDisplayShowCustomEnabled(true);
getSupportActionBar().setCustomView(R.layout.layout_custom_action_bar);
}
void showCreateNoteFragment(){
CreateNoteFragment createNoteFragment = CreateNoteFragment.newInstance();
fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.add(R.id.fragment_cardView, createNoteFragment);
fragmentTransaction.commit();
fragmentCardView.setVisibility(View.VISIBLE);
}
#Override
public void onClick(View v) {
if (v == newNoteButton)
showCreateNoteFragment();
}
}
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#F2F2F2"
tools:context=".MainActivity">
<ListView
android:id="#+id/notes_listView"
android:layout_width="match_parent"
android:layout_height="667dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
<Button
android:id="#+id/new_note_button"
android:layout_width="350dp"
android:layout_height="50dp"
android:layout_marginTop="27dp"
android:fontFamily="#font/nunito_bold"
android:text="#string/new_note_button_string"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/notes_listView"/>
<androidx.cardview.widget.CardView
android:id="#+id/fragment_cardView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="100dp"
android:layout_marginBottom="100dp"
android:layout_marginStart="25dp"
android:layout_marginEnd="25dp"
android:visibility="invisible"/>
</androidx.constraintlayout.widget.ConstraintLayout>
CreateNoteFragment.java
package com.example.notepadapplication;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
public class CreateNoteFragment extends Fragment implements View.OnClickListener {
private EditText inputEditText;
public CreateNoteFragment() {
// Required empty public constructor
}
static CreateNoteFragment newInstance(){
return new CreateNoteFragment();
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_create_note, container, false);
inputEditText = rootView.findViewById(R.id.input_editText);
Button saveButton = rootView.findViewById(R.id.save_button);
saveButton.setOnClickListener(this);
return rootView;
}
#Override
public void onClick(View v) {
String saveButtonText = inputEditText.getText().toString();
}
}
fragment_create_note.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
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"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_marginTop="100dp"
android:layout_marginBottom="100dp"
android:layout_marginStart="25dp"
android:layout_marginEnd="25dp"
android:background="#F2F2F2"
tools:context=".CreateNoteFragment">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/header_textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:text="#string/display_fragment_header_string"
android:layout_marginTop="10dp"
android:textAlignment="center"
android:textSize="20sp"
android:fontFamily="#font/nunito_bold"/>
<View
android:id="#+id/divider_view"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="5dp"
android:layout_marginStart="15dp"
android:layout_marginEnd="15dp"
android:layout_below="#id/header_textView"
android:background="#000000" />
<EditText
android:id="#+id/input_editText"
android:layout_width="match_parent"
android:layout_height="475dp"
android:layout_below="#id/divider_view"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
android:layout_marginTop="20dp"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:padding="10dp"
android:inputType="textMultiLine"
android:gravity="top"
android:background="#FFFFFF"
tools:ignore="Autofill,LabelFor,TextFields" />
<Button
android:id="#+id/save_button"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="10dp"
android:text="#string/save_button_string"
android:fontFamily="#font/nunito_bold"/>
</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
Could anyone check why the fragment isn't popping up? Thanks for the help, guys.
P.S.: I think that the application might become a little bloated because of all the ViewGroups that I'm using. If you guys have a better way to design this, by all means, I would love any input.
When I press the button to add a new note, the fragment does not pop up.
This is expected since your button doesn't know what to do when pressed.
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setActionBar();
newNoteButton = findViewById(R.id.new_note_button);
// Button will call activity's onClick whenever it's clicked
newNoteButton.setOnClickListener(this);
fragmentCardView = findViewById(R.id.fragment_cardView);
}
I have lots of layouts and activites and fragments. There are tabs in one activity called Hastane1 and it has four tabs in it. They don't have any problem but one of them has. I wanted to send a data from one Activity to a Fragment. They are seperate. Fragment is in Hastane1 activity but Haberlesme1 activity is in another place. It supposed to send the numbers which i entered in the activity called Haberlesme1 to the textView in the fragment called Hastane1Tab3Frag which is a tab of Hastane1.
The Android Studio itself doesn't have any errors but when i run the app on my phone, it stops when i pressed the button called "Gönder" (#id/button8).
Haberlesme1 (Activity):
package com.example.projev021.İllerPackage.KocaeliPackage.GebzePackage.GebzeFragments.Hastane1Fragments;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.example.projev021.HaberlesmePackage.Haberlesme1;
import com.example.projev021.R;
public class Hastane1Tab3Frag extends Fragment {
Button goster;
TextView sonucText;
int sayi=0;
Haberlesme1.Ogrenci ogr;
#Nullable
#Override
public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState) {
View v= inflater.inflate(R.layout.hastane1_tab3,container,false);
goster=(Button)v.findViewById(R.id.button13);
sonucText = (TextView)v.findViewById(R.id.textView3);
goster.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
sonucText.setText(sayi);
}
});
return v;
}
public void sendData(int birinciSayi) {
this.sayi=birinciSayi;
}
public void sendOgrenci(Haberlesme1.Ogrenci ogrenci) {
this.ogr=ogrenci;
}
}
haberlesme1.xml:
<?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">
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:fontFamily="#font/lineto_circular_black"
android:text="#string/kackisivar"
android:textSize="50sp"/>
<EditText
android:id="#+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:ems="10"
android:inputType="number"
android:text="" />
<Button
android:id="#+id/button8"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="50dp"
android:layout_marginEnd="50dp"
android:layout_marginTop="20dp"
android:layout_marginBottom="5dp"
android:background="#drawable/buttonshape"
android:fontFamily="#font/lineto_circular_black"
android:text="#string/gonder"
android:textColor="#FFC107"
android:textSize="30sp"
android:onClick="calistir"/>
</LinearLayout>
Hastane1Tab3Frag (Fragment):
package com.example.projev021.İllerPackage.KocaeliPackage.GebzePackage.GebzeFragments.Hastane1Fragments;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.example.projev021.HaberlesmePackage.Haberlesme1;
import com.example.projev021.R;
public class Hastane1Tab3Frag extends Fragment {
Button goster;
TextView sonucText;
int sayi=0;
Haberlesme1.Ogrenci ogr;
#Nullable
#Override
public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState) {
View v= inflater.inflate(R.layout.hastane1_tab3,container,false);
goster=(Button)v.findViewById(R.id.button13);
sonucText = (TextView)v.findViewById(R.id.textView3);
goster.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
sonucText.setText(sayi);
}
});
return v;
}
public void sendData(int birinciSayi) {
this.sayi=birinciSayi;
}
public void sendOgrenci(Haberlesme1.Ogrenci ogrenci) {
this.ogr=ogrenci;
}
}
hastane1tab3.xml:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/container">
<LinearLayout
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:layout_marginStart="10dp"
android:fontFamily="#font/lineto_circular_black"
android:text="#string/kisisayisi_"
android:textSize="50sp" />
<TextView
android:id="#+id/textView3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:fontFamily="#font/lineto_circular_black"
android:text=""
android:textSize="100sp"
android:textColor="#000000" />
<Button
android:id="#+id/button13"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="50dp"
android:layout_marginEnd="50dp"
android:layout_marginTop="20dp"
android:layout_marginBottom="5dp"
android:background="#drawable/buttonshape"
android:fontFamily="#font/lineto_circular_black"
android:text="#string/goster"
android:textColor="#FFC107"
android:textSize="30sp"/>
</LinearLayout>
</FrameLayout>
And the screenshots:
Hello i create Reader QR Code using ZXING Scanner in Android Studio
i want increase height and width scanning area green border see this image.
Can you have solution to set height and width scanning area (green border) ?
This is my code MainActivity.java
package com.example.gajelo.barcodereader;
import android.widget.RelativeLayout;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import com.google.zxing.Result;
import me.dm7.barcodescanner.zxing.ZXingScannerView;
public class MainActivity extends AppCompatActivity implements ZXingScannerView.ResultHandler {
private ZXingScannerView mScannerView;
#Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.activity_main);
mScannerView = new ZXingScannerView(this);
RelativeLayout rl = (RelativeLayout) findViewById(R.id.relative_scan);
rl.addView(mScannerView);
mScannerView.setResultHandler(this);
mScannerView.startCamera();
}
#Override
protected void onPause() {
super.onPause();
mScannerView.stopCamera();
}
#Override
public void handleResult(Result result) {
Log.w("handleResult", result.getText());
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(result.getText());
AlertDialog alertDialog = builder.create();
alertDialog.show();
}
}
CaptureFragment.java
package com.example.gajelo.barcodereader;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.os.Bundle;
import me.dm7.barcodescanner.zxing.ZXingScannerView;
public class CaptureFragment extends Fragment {
private ZXingScannerView mScannerView;
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle saveInstanceState) {
View view = inflater.inflate(R.layout.capture, container, false);
return view;
}
}
activity_main.xml
<?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_main"
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.example.gajelo.barcodereader.MainActivity">
<TextView
android:text="This Is Main Activity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView2"
android:textSize="30sp"
android:textStyle="normal|bold"
android:textColor="#android:color/black"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="22dp" />
<TextView
android:text="Scan QR CODE"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView"
android:textSize="30sp"
android:textStyle="normal|bold"
android:textColor="#android:color/black"
android:layout_alignParentBottom="true"
android:layout_alignLeft="#+id/textView2"
android:layout_alignStart="#+id/textView2"
android:layout_marginLeft="23dp"
android:layout_marginStart="23dp"
android:layout_marginBottom="54dp" />
<RelativeLayout
android:id="#+id/relative_scan"
android:layout_width="300dip"
android:layout_height="300dip"
android:layout_centerInParent="true"
android:layout_gravity="center">
</RelativeLayout>
</RelativeLayout>
capture.xml
<?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_main"
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">
</RelativeLayout>
You can use
app:zxing_framing_rect_width="200dp"
and app:zxing_framing_rect_height="200dp" to increase height
<com.journeyapps.barcodescanner.DecoratedBarcodeView
android:id="#+id/zxing_barcode_scanner"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="36dp"
app:zxing_framing_rect_width="200dp"
app:zxing_framing_rect_height="200dp"
app:zxing_preview_scaling_strategy="fitXY"
app:zxing_use_texture_view="false"
/>
How can I change or add more code to make this app to stop crashing? This activity is called "WhatBin", I simply wanted to make a button listen to when a person would click and change a text view. (VIEW PICTURES BELOW FOR MORE DETAILS.)
PICTURES: http://imgur.com/a/ODvHb
package com.example.tiffany.whatbin;
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.View;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import org.w3c.dom.Text;
public class WhatBin extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_what_bin);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
final TextView txt_answer = (TextView) findViewById(R.id.txt_answer);
Button btn_go = (Button) findViewById(R.id.btn_go);
btn_go.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
txt_answer.setText("Marker - Recycle Bin");
}
});
};
}
HERE IS THE XML 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"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_padddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:showIn="#layout/activity_what_bin" tools:context=".WhatBin">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Go"
android:id="#+id/btn.go"
android:layout_marginBottom="113dp"
android:textColor="#drawable/abc_dialog_material_background_dark"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textEdit"
android:layout_alignBottom="#+id/btn.go"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_toLeftOf="#+id/btn.go"
android:layout_toStartOf="#+id/btn.go" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="#string/instructiontext"
android:id="#+id/textinstruc"
android:layout_below="#+id/textEdit"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_toLeftOf="#+id/btn.go"
android:layout_toStartOf="#+id/btn.go" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="#string/txt.1"
android:id="#+id/txt.answer"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
UPDATE
You are currently using abc_dialog_material_background_dark as textcolor. As you can see in the source of this resource, it is basically a shape. And, shape cannot be used for textcolor.
In your XML file at line 17 you have used a color. That color is of wrong type. My guess, you have used a drawable instead of a color.
Post your activity_what_bin.xml for further explanation.
I added a new font called cgib.ttf, I went to MainActivity.java to add the 2 titleTexts
Here is the activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#1d72c3"
tools:context=".MainActivity" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:orientation="vertical" >
<TextView
android:id="#+id/title"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:text="#string/titleText"
android:textColor="#ffffff"
android:textSize="55sp" />
<TextView
android:id="#+id/kark"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:text="#string/titleText2"
android:textColor="#ffffff"
android:textSize="30sp" />
</LinearLayout>
Here is the MainActivity.java
package com.sa.damas;
import android.R;
import android.app.Activity;
import android.graphics.Typeface;
import android.os.Bundle;
import android.widget.TextView;
public class MainActivity extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initTypeFace();
}
private void initTypeFace() {
Typeface cgib = Typeface.createFromAsset(getAssets(), "fonts/cgib.ttf");
TextView titleText=(TextView) findViewById(R.id.title);
titleText.setTypeface(cgib);
TextView titleText2=(TextView) findViewById(R.id.kark);
titleText2.setTypeface(cgib);
}
}
The title is fixed and the second (kark) couldnt be found in the list
Replace import android.R; with import R;
android.R contains the system resources, not your project's resources