【ANDROID STUDIO】 app widget

package com.example.appwidget;

import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.Context;
import android.content.Intent;
import android.widget.RemoteViews;

public class HomescreenWidgetProvider extends AppWidgetProvider {

@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
super.onUpdate(context, appWidgetManager, appWidgetIds);

for (int count = 0; count < appWidgetIds.length; count++) {
RemoteViews appWidgetLayout = new
RemoteViews(context.getPackageName(),
R.layout.widget);
Intent intent = new Intent(context, MainActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
appWidgetLayout.setOnClickPendingIntent(R.id.analogClock, pendingIntent);
appWidgetManager.updateAppWidget(appWidgetIds[count], appWidgetLayout);
}
}
}

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<AnalogClock
android:id="@+id/analogClock"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>

Androidmanifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.appwidget">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<receiver android:name=".HomescreenWidgetProvider" >
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data android:name="android.appwidget.provider"
android:resource="@xml/appwidget_info" />
</receiver><activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>

【ANDROID STUDIO】 Runtime Fragment

package com.example.runtimefragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.fragment.app.Fragment;

public class FragmentOne extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_one,
container, false);
}
}

package com.example.runtimefragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.fragment.app.Fragment;

public class FragmentTwo extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_two,
container, false);
}
}

package com.example.runtimefragment;

import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;

import android.os.Bundle;
import android.view.View;

public class MainActivity extends AppCompatActivity {

FragmentOne mFragmentOne;
FragmentTwo mFragmentTwo;
int showingFragment=0;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

mFragmentOne = new FragmentOne();
mFragmentTwo = new FragmentTwo();
getSupportFragmentManager().beginTransaction().add(R.id.frameLayout, mFragmentOne).commit();
showingFragment = 1;
}

public void switchFragment(View view) {
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
if (showingFragment == 1) {
fragmentTransaction.replace(R.id.frameLayout, mFragmentTwo);
showingFragment = 2;
} else {
fragmentTransaction.replace(R.id.frameLayout, mFragmentOne);
showingFragment = 1;
}
fragmentTransaction.commit();
}
}

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout android:id="@+id/frameLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/buttonSwitch"
android:layout_alignParentTop="true">
</FrameLayout>
<Button android:id="@+id/buttonSwitch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Switch"
android:layout_alignParentBottom="true"
android:layout_centerInParent="true"
android:onClick="switchFragment"/>
</RelativeLayout>

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Fragment One"
android:id="@+id/textView"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Fragment Two"
android:id="@+id/textView"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>

【Vuejs】 Random roll call system

【ANDROID STUDIO】 Fragment Communication

package com.example.fragmentcommunication;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

public class DetailFragment extends Fragment {

public static String KEY_COUNTRY_NAME = "KEY_COUNTRY_NAME";


@Override
public View onCreateView(LayoutInflater inflater,
ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_detail, container, false);
}

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);

Bundle bundle = getArguments();

if (bundle != null && bundle.containsKey(KEY_COUNTRY_NAME)) {
showSelectedCountry(bundle.getString(KEY_COUNTRY_NAME));
}
}

public void showSelectedCountry(String countryName) {
((TextView) getView().findViewById(R.id.textViewCountryName)).setText(countryName);
}
}
package com.example.fragmentcommunication;

import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.FragmentTransaction;

import android.os.Bundle;
import android.widget.FrameLayout;

public class MainActivity extends AppCompatActivity {

boolean mDualPane;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

MasterFragment masterFragment = null;
FrameLayout frameLayout = findViewById(R.id.frameLayout);
if (frameLayout != null) {
mDualPane = false;
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
masterFragment = (MasterFragment) getSupportFragmentManager()
.findFragmentByTag("MASTER");
if (masterFragment == null) {
masterFragment = new MasterFragment();
fragmentTransaction.add(R.id.frameLayout, masterFragment, "MASTER");
}
DetailFragment detailFragment = (DetailFragment)
getSupportFragmentManager().findFragmentById(R.id.frameLayoutDetail);
if (detailFragment != null) {
fragmentTransaction.remove(detailFragment);
}
fragmentTransaction.commit();
} else {
mDualPane = true;
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
masterFragment = (MasterFragment) getSupportFragmentManager()
.findFragmentById(R.id.frameLayoutMaster);
if (masterFragment == null) {
masterFragment = new MasterFragment();
fragmentTransaction.add(R.id.frameLayoutMaster, masterFragment);
}
DetailFragment detailFragment = (DetailFragment) getSupportFragmentManager()
.findFragmentById(R.id.frameLayoutDetail);
if (detailFragment == null) {
detailFragment = new DetailFragment();
fragmentTransaction.add(R.id.frameLayoutDetail, detailFragment);
}
fragmentTransaction.commit();
}
masterFragment.setOnMasterSelectedListener(new MasterFragment.OnMasterSelectedListener() {
@Override
public void onItemSelected(String countryName) {
sendCountryName(countryName);
}
});
}


private void sendCountryName(String countryName) {
DetailFragment detailFragment;
if (mDualPane) {
//Two pane layout
detailFragment = (DetailFragment) getSupportFragmentManager().findFragmentById(R.id.frameLayoutDetail);
detailFragment.showSelectedCountry(countryName);
} else {
// Single pane layout
detailFragment = new DetailFragment();
Bundle bundle = new Bundle();
bundle.putString(DetailFragment.KEY_COUNTRY_NAME, countryName);
detailFragment.setArguments(bundle);
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.frameLayout, detailFragment);
fragmentTransaction.addToBackStack(null);
fragmentTransaction.commit();
}
}
}
package com.example.fragmentcommunication;

import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.TextView;

import androidx.fragment.app.ListFragment;

public class MasterFragment extends ListFragment {

public interface OnMasterSelectedListener {
public void onItemSelected(String countryName);
}

private OnMasterSelectedListener mOnMasterSelectedListener = null;

public void setOnMasterSelectedListener(OnMasterSelectedListener listener) {
mOnMasterSelectedListener = listener;
}

public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);

String[] countries = new String[]{"China", "France",
"Germany", "India", "Russia", "United Kingdom",
"United States"};

ListAdapter countryAdapter = new ArrayAdapter<String>(
getActivity(), android.R.layout.simple_list_item_1,
countries);

setListAdapter(countryAdapter);

getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);

getListView().setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (mOnMasterSelectedListener != null) {
mOnMasterSelectedListener.onItemSelected(((
TextView) view).getText().toString());
}
}
});
}
}
//layout

<?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"
tools:context=".MainActivity">

<FrameLayout android:id="@+id/frameLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView android:id="@+id/textViewCountryName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
//layout-land

<?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="horizontal">
<FrameLayout android:id="@+id/frameLayoutMaster"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"/>
<FrameLayout android:id="@+id/frameLayoutDetail"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"/>
</LinearLayout>

【ANDROID STUDIO】 Fragment Back Stack

package com.example.fragmentbackstack;

import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;

import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity
implements FragmentManager.OnBackStackChangedListener {

Button mButtonNext;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

getSupportFragmentManager().addOnBackStackChangedListener(this);

mButtonNext = findViewById(R.id.buttonNext);
mButtonNext.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction =
fragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.frameLayout, new FragmentTwo());
fragmentTransaction.addToBackStack(null);
fragmentTransaction.commit();
mButtonNext.setVisibility(View.INVISIBLE);
}
});

FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction =
fragmentManager.beginTransaction();
fragmentTransaction.add(R.id.frameLayout, new FragmentOne());
fragmentTransaction.addToBackStack(null);
fragmentTransaction.commit();
}

@Override
public void onBackPressed() {
if (getSupportFragmentManager().getBackStackEntryCount() == 2) {
super.onBackPressed();
mButtonNext.setVisibility(View.VISIBLE);
} else {
finish();
}
}

@Override
public boolean onOptionsItemSelected(MenuItem menuItem) {
if (menuItem.getItemId() == android.R.id.home) {
onBackPressed();
return true;
} else {
return super.onOptionsItemSelected(menuItem);
}
}

@Override
public void onBackStackChanged() {
Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.frameLayout);
if (fragment instanceof FragmentOne) {
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
} else if (fragment instanceof FragmentTwo) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
}
}

package com.example.fragmentbackstack;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.fragment.app.Fragment;

public class FragmentOne extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_one,
container, false);
}
}

package com.example.fragmentbackstack;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.fragment.app.Fragment;

public class FragmentTwo extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_two,
container, false);
}
}
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<FrameLayout
android:id="@+id/frameLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/buttonNext"
android:layout_alignParentTop="true"></FrameLayout>

<Button
android:id="@+id/buttonNext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerInParent="true"
android:text="Next" />
</RelativeLayout>
fragment_one.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent">
<TextView android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Fragment One"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
fragment_two.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent">
<TextView android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Fragment Two"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>

【GAMEMAKER】 multiplication table

Information about object: obj_multiplication
Sprite:
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Draw Event:
execute code:

///Draw Table
for (var i = 1; i < 13; i += 1)//create loop
for (var j = 1; j < 13; j += 1)//create loop
{
value=i*j;//calculare value
draw_text(i*30,j*30,value);//draw value at position
}

How the New York Times led to the fall of Assad

Anti-semitism by the New York Times actually made Israel safer ͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­...

Contact Form

Name

Email *

Message *